Repository navigation
Check a container's release in its session object, not in the outbound handler - #6568
Merged
Merged
Conversation
…ndler's For some seconds after a deploy Cloudflare can run a session object on the previous Worker version while it runs the object's outbound handler, `SessionOutbound`, on the deployed one. The object then started the previous image, as its code names it, and the handler refused that container's first read of its records, since the handler compared the container's `Leaf-Release` with its own manifest. The container exited 1 and the visitor's request answered 500. Seen on #6565's deploy at 19:11 PT: 14 s after the new version went live, the deploy check's fresh session ran `LeafSession` on version 4cfec23e and `SessionOutbound` on fa6d68b8, and the store answered 409 "the page store serves release 9f3b4cc8…". It was the one failed start in the three production deploys since #6550. The object now passes the release of its own code in the handler's props, and the store holds a container to that. A container the object started on its own release reads and writes its records whichever version runs the handler; once the object restarts on the deployed code it routes a running container under the new release, which the store refuses, and its first request stops it, as before. The handler that runs during the next deploy's switch is this code, so the fix holds from that deploy on.
leaf-agent
previously approved these changes
Nov 20, 2026
…live Review found that holding the handler to the object's release in props still admits an old container's write when the object restarts on the deployed code while that request is on its way: the handler had passed it, and the object, now on the new code, stored it under the new release. Only the object knows, as it handles a request, which code it runs. So `SessionOutbound` now passes each page store request to the object's `pageStore`, which refuses a container on another release than its own code's before reading or writing anything, and the props and the five separate store methods go.
… saved-records test's stand-in
leaf-agent
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For some seconds after a deploy, Cloudflare can run a session object on the previous Worker version while it runs the object's outbound handler,
SessionOutbound, on the deployed one. The object then starts the previous image, as its code names it. The handler refused that container's first read of its records because it compared the container'sLeaf-Releasewith its own manifest, so the container exited 1 and the visitor's request answered 500.The release check now happens in the session object, which owns the records.
SessionOutboundpasses each page store request to the object'spageStore, which refuses a container on another release than the object's own code before reading or writing anything. The object's five separate store methods are folded into it. A container the object started on its own release can read and write its records whichever version runs the handler. Once the object restarts on the deployed code, the same check refuses the previous image, including a request already on its way when the restart happened, and the object's first request stops that container, as before.What to weigh: in those seconds, a previous-release container can still write its session's records while the deployed code is live elsewhere.
storage.tsnow says the store guarantees deployed-image writes from the moment the object moves to the deployed code. Records already outlive deploys at the same page protocol and store format, and the maintainer ranked such incompatibility unlikely. The code that runs during the next deploy's switch is this code, so the fix holds from that deploy on; during this PR's own deploy an older object lackspageStore, which fails the same starts the old rule failed.Evidence: on #6565's deploy at 19:11 PT, 14 s after the new version went live, the deploy check's fresh session ran
LeafSessionon version 4cfec23e andSessionOutboundon fa6d68b8, and the store answered 409 "the page store serves release 9f3b4cc8…". It is the one failed container start on production in the five deploys since #6550 went live. A new test runs the object and the handler on different releases, and fails under the old rule. An independent Codex review of a first version, which passed the object's release to the handler in props, found the restart case above, which moved the check into the object; its review of this version, run in local workerd, found the 1 MiB bound and error reasons intact across the RPC. On the dev site, the site check and a real agent turn, which restores and saves its records throughpageStore, passed.pnpm run check:workerpasses.Found while measuring deploys for the deploy page the maintainer is following.