Skip to content

Negative cargo race condition bug in transfer cargo #110

Open

Description

@rj45

I have a bugged ship, it fails to fetch on both the ships listing and single ship endpoints. Here is the returned error:

{"error":{"code":3000,"message":"The server did not return a valid response. If you want to help you can file an issue here: https://github.com/SpaceTradersAPI/api-docs.","requestId":"019790c7-bd34-71e9-b907-36ed2e4c82c6"}}

It's ship RJ45-22 in the current reset (2025-06-15). It's a mining drone.

I have had this happen on both the prod and staging servers.

There's a chance it's a race condition in the cargo transfer code 'cause my client used to not be super careful to ensure that the cargo of the ship it's transferring to was not full, and I had several agents all transferring at the same time, which could result in two transfer cargo requests at the same time to the server for different ships to both fill the target ship (which was a hauler).

I have since changed my logic so the hauler pulls cargo from the drones rather than the drones pushing to it so if I am right it shouldn't happen again. But I will report if that's not the case.

edit: the /cargo endpoint fails, but the /nav endpoint succeeds. So a bit more evidence that the cargo transfer is the issue.

Activity

  1. rj45 commented on Jun 29, 2025

    @rj45
    Author

    Just so you know, it happened again this reset. Same issue, my miners somehow managed to get -4 water ice. It was basically a race condition between one ship (in one process) jettisoning the water ice, and another ship (in another process) trying to transfer it. I am guessing they hit the server at the same time resulting in both of them succeeding, but one ending up with negative water ice in its cargo hold.

  2. changed the title [-]Bugged ship, happens on prod and on staging[/-] [+]Negative cargo race condition bug in transfer cargo[/+] on Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions