Repository navigation
Let a previous-release leaf.page container start and be recognized during a rollout - #6457
Merged
Merged
Conversation
…ng a rollout Cloudflare activates a new Worker before its container image rolls out, so for some minutes after a deploy a session's container can start on the previous image. The edge already replaces such a container's answers (`rollingOut`), but only once the container answers. On 2026-11-19 at 01:06 UTC, right after #6441 deployed, previous-image containers read the new Durable Object's `/records` snapshot, now `{"records": ..., "drafts": ...}`, took `records` for a page root, and exited on `KeyError: 'records'` before serving. With no answer to recognize, the edge passed the Durable Object's 500 through, and a visitor on /how-it-works saw "Hit a problem — trying again" on `api/state`, `api/news`, `api/event` and `api/user-view` until the rollout finished. Each store request now names its container's release in `Leaf-Release`. The `leaf-state.internal` handler refuses a release other than the Worker's with 409 before any operation, and `restore` takes that refusal as a cue to start without the session's record and without publishing (`page_restore_refused`). The container then boots, its answers name its own release, and the edge's rollout path takes over, whatever the new release changed in the record. That one check replaces the per-operation release check: the `release` fields in the publication and drafts bodies, the `leaf_pages.release` column, and the release comparison in `PageStore.checkRelease` (now `checkRoot`, at prepare and drafts saves) are gone. A container already on the previous image when this deploys sends no header, so it is refused and still fails to start once, as on 2026-11-19. Behavior changes the tests now hold: a store request from another release is refused with 409 before it reads or writes (`index.test.ts`), and a container refused at restore starts without the record (`test_saved_records.py`). The store's root check moved from commit to prepare (`storage.test.ts`).
…ncluded The edge recognizes a previous release's container during a rollout by the `Leaf-Release` header on its answer (`rollingOut`), but the website adapter stamped it only on page routes. A container on the previous image asked for a page only the new release has answered 404 without it, so the edge passed the 404 through for the minutes the rollout ran, where it should have answered with the published state or a 503 to retry. Codex found this reviewing the previous commit and reproduced it against the adapter. `PageEndpoint._delivery_headers` now names the release on every response of a server that runs one, which only the website adapter does; local servers' headers don't change. `test_a_website_example_uses_the_real_page_server` holds the 404 case.
leaf-agent
approved these changes
Nov 19, 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.
After a deploy, Cloudflare runs the new Worker while some session containers still start on the previous image. The edge replaces such a container's answers (
rollingOut), but only once the container answers with itsLeaf-Release. Right after #6441 deployed (2026-11-19 01:06 UTC), previous-image containers read the new Durable Object's/recordssnapshot, took its newrecordskey for a page root, and exited onKeyError: 'records'before serving. The edge passed the Durable Object's 500 through, and a visitor on /how-it-works saw "Hit a problem — trying again" until the rollout finished.leaf-state.internalhandler refuses another release with 409 before any operation, andrestoretakes that refusal as a cue to start without the session's record and without publishing. That one check replaces the per-operation release check, so thereleasefields in the publication and drafts bodies and theleaf_pages.releasecolumn are gone.To weigh: the deploy of this change still crashes previous-image containers once, since they send no header and treat the 409 as a failure. A stale sample URL can still wake an older release's Durable Object with the current image, which the header check accepts; that is left as a follow-up.
Codex reviewed the first commit and found the 404 case. Tests:
pnpm run check:worker,tests/process/website_server, and the saved-record journey test.