Repository navigation
Keep the site manifest, not a promise of it, across a Worker isolate's requests - #6565
Merged
Merged
Conversation
…s requests The Worker read its site manifest once per isolate and shared the pending promise with every request that arrived while it loaded. Under Workers' cross-request promise rule a promise settles only in the request that made it, so when that request ended first, as when its browser navigated away or startup recovery reloaded the page, the promise never settled. The map kept it, since only a rejection removed it, and every later request in that isolate failed with a 500 until Cloudflare retired the isolate. A dev deploy at 18:31 PT on 19 November met this: loading the dev root once a second, 86 requests failed this way over two and a half minutes in the new version's isolates, static release files and the document among them, and one load still had not started a minute later. The next dev deploy, with this change and the same loads, had no failed request among 129 loads. Production logged no such failure in the six hours before. The isolate now keeps the manifest once a request has read it. Requests that arrive before then each read it themselves.
leaf-agent
approved these changes
Nov 20, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 20, 2026
…d handler (#6568) 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's `Leaf-Release` with 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. `SessionOutbound` passes each page store request to the object's `pageStore`, 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.ts` now 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 lacks `pageStore`, 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 `LeafSession` on version 4cfec23e and `SessionOutbound` on 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 through `pageStore`, passed. `pnpm run check:worker` passes. Found while measuring deploys for the deploy page the maintainer is following. > _This was written by Claude Code on behalf of max-sixty_
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.
The Worker shared one pending promise of the site manifest among the requests a fresh isolate took while it loaded. Workers settle a promise only in the request that created it, so when that first request ended early, as when its browser navigated away or Leaf's startup recovery reloaded the page, the promise never settled and every later request in the isolate answered 500 until Cloudflare retired it. Fresh isolates are what a deploy starts, and reloads are what a failed start makes, so the two meet in the seconds after a deploy.
The isolate now keeps the manifest itself once a request has read it, and requests before then each read their own.
Evidence: loading the dev site once a second through a dev deploy at 18:31 PT, 86 requests failed this way over 2.5 minutes, with "This promise was created by a request that has since ended" in the logs, and one load never started. The next dev deploy with this change, under the same loads, failed none of 129. Production logged no such failure in the six hours before; nothing in Node's test environment can reproduce the rule, so no test covers it.
Found while measuring page loads through deploys for the deploy page the maintainer is following.
pnpm run check:workerpasses.