Skip to content

Fix race condition with sending a request while container is stopping#148

Open
rushilmehra wants to merge 1 commit intomainfrom
rm/container-shutdown-race
Open

Fix race condition with sending a request while container is stopping#148
rushilmehra wants to merge 1 commit intomainfrom
rm/container-shutdown-race

Conversation

@rushilmehra
Copy link

Due to some quirks in the runtime, it's possible for the DO to send a request to a container when it thinks the container is in a running state, but while the request is in flight, the container stops and the monitor promise resolves. This results in an error, and instead of retrying we throw a 500 error. Instead, recognize this case and restart the container.

This is a bandage solution, but we will follow up with some improvements to the runtime that will clean up the state management required in this DO class.

Due to some quirks in the runtime, it's possible for the DO to send a
request to a container when it thinks the container is in a running
state, but while the request is in flight, the container stops and the
monitor promise resolves. This results in an error, and instead of
retrying we throw a 500 error. Instead, recognize this case and restart
the container.

This is a bandage solution, but we will follow up with some improvements
to the runtime that will clean up the state management required in this
DO class.
@rushilmehra rushilmehra requested a review from a team as a code owner February 2, 2026 16:45
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/containers/@cloudflare/containers@148

commit: bde0a0a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants