Skip to content

Stop handling leaf.page's rollout skew: only the edge names a release - #6474

Merged
max-sixty merged 5 commits into
mainfrom
lighter-draft-dot
Nov 19, 2026
Merged

max-sixty merged 5 commits into
mainfrom
lighter-draft-dot

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf.page stops handling the minutes after a deploy when a visitor's container still runs the previous image. Only the edge names a release now: the Worker stamps its own on every answer it passes on, and a tab reloads on the first answer from another release. The container's Leaf-Release stamp, rollingOut and its cookie clear, the browser's release probe before reloading, the live sample's retry loop and the deploy gate's reading of the edge's 503 are gone. The page store still refuses a container on another release, so a previous image fails to start rather than reading or writing the new release's records. Without that refusal, a previous image saves a document that loads its own release's assets, and the page reload-looped (41 reloads in 15 s) until the next deploy.

The maintainer judged the window code not worth its weight. A week of unsampled production logs agrees: 194 deploys, windows of a median 2.5 minutes, and all 1,243 answers the code gave went to the deploy gate's own probes, with no real visitor among them. Its static-state branch never fired. The one real failure in a window, on 2026-11-18 on /how-it-works, was a container that crashed before answering. The Worker then set the active cookie and Leaf-Session: active on the SDK's 500, which pinned the session to the crashed container. The second commit lets only Python's own answer mark a session active: the Worker passes on Python's Leaf-Session instead of stamping its own, and sets the cookie only when that header is there.

To weigh: during a rollout, a visitor who sends sees "Not through yet — trying again…" until the send goes through, and a live sample opened then shows "sample: HTTP 500" until Reset. At current traffic that is about 0.4 visitors a week other than the maintainer, by a model; none were recorded. rollout_active_grace_period = 0 goes, since 0 is Wrangler's default. Deploying this commit lets previous-image containers, which still run the old start-without-record code, acknowledge a write that is then lost, for that one rollout.

Tests: pnpm run check (Worker 93, runtime 1066), tests/process/website_server, dev/tests/process/test_website_server.py, and the browser tests for samples, the event 503 and the layer probe. The visitor cases ran in Chromium against the real website adapter, with Playwright routes standing in for the Worker. Codex reviewed the branch; its two findings (a new layer blocking the release reload, and the Worker's own session stamp) are fixed here.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 4 commits November 18, 2026 19:21
For the minutes after a deploy that Cloudflare rolls the container image, a new
release's session can start a container on the previous image. Leaf carried four
mechanisms for that window: containers stamped their release on every answer, the
Worker replaced a foreign one with the published state or a 503 with Retry-After
(`rollingOut`), the browser probed the document source before reloading on a
foreign release, and a sample's allocation retried through the 503 for up to ten
minutes, announcing a `waiting` notice that released the page's presentation.

Now only the edge names a release. The Worker stamps its own on every answer it
passes on from a container, samples included, and containers stamp none. A foreign
release can then only mean the edge has moved past the document, so the browser
reloads at once. The page store keeps refusing a container on another release, and
that refusal now ends the container's start instead of letting it serve without the
session's record. So nothing a previous image reads or writes reaches the new
release's Durable Object, whatever changed between the two formats.

Removed: `rollingOut` and its check, `clearActiveCookie`, the container's
`Leaf-Release` stamp, the restore's 409 branch (`FOREIGN_RELEASE`,
`page_restore_refused`), `RequestError.retryAfter`, the sample's rollout retry
(`ROLLOUT_MS`) and its `waiting` notice in `sample.js` and `lf-sample.js`, the
release lines in `sourceMovedOn`, the deploy gate's `STILL_STARTING` reading of
the 503, and `rollout_active_grace_period = 0`, which Wrangler defaults to. The
Worker's `http_error` records now tell Python's answers by `Leaf-Session`. Startup
recovery (`bootstrap.js`) is unchanged: a tab whose release's assets are gone still
asks for one new document.

What a visitor sees, measured against the website adapter in Chromium with routes
standing in for the Worker:

- A tab opened before a deploy, once answers name the new release: one reload,
  0.6 s after the next state read, with no probe before it; 2 documents in 10 s.
- A visitor who comments while their container is on the previous image, with
  every container request answering the SDK's 500 for 13 s: the message shows
  "Queued for Agent", the field says "Not through yet — trying again…", the send
  repeats every 2 s, no reload, and the comment is in the log 2 s after the window.
- The adapter process on release A against a store on release B exits with
  `PageStoreRefused: /records answered 409` before serving; the store answered no
  restore.
- Without the store's refusal, an image on A saves a document naming
  `data-lf-release` A and loading `/_leaf-release/A/...` into the session. Served
  back with the edge's B on every answer, that page reloaded 41 times in 15 s. That
  is why the refusal stays.

A reload during the window now shows the Containers SDK's 500 page, where the edge
used to serve the published projection.

Tests: `pnpm run check` (worker 92, runtime 1065), `tests/process/website_server`
(97), `dev/tests/process/test_website_server.py` (29), and the browser tests that
touch samples, the event 503 and the layer probe (15). Removed tests covered only
the deleted mechanisms: the Worker's rollout answers, `request-wait.test.mjs`, and
the four sample-through-a-rollout browser tests.
The Worker set a page's active cookie on any answer passed on from a
container, the Containers SDK's own 500 included. A visitor whose container
exited while starting, as previous-image containers do during a rollout, was
then pinned to it: every later read went to the dead container until the
rollout replaced it. That is how the 2026-11-18 17:05 PT report on
/how-it-works kept failing. Only Python's answers name a session, so the
cookie now waits for one.
…ark a session active

A tab now checks an answer's release before its layer. A new release's answer
can name a new layer too, and the layer check asks this release's registry,
which is gone once the edge has moved on, so the tab used to keep refusing
answers after the rollout until the visitor reloaded by hand.

The Worker no longer stamps Leaf-Session: active on what it passes on from a
container. Python names its session on every answer, so the Containers SDK's
own 500 for a container that never answered now names none, and the browser
stays passive as the cookie already did. The Worker tests that asserted the
stamp on mocks without Python's header drop that assertion; Python's header is
asserted in tests/process/website_server/test_routes.py.

Both found by a Codex review of the branch.

Co-Authored-By: Claude <[email protected]>
leaf-agent
leaf-agent previously approved these changes Nov 19, 2026
Comment thread docs/website.html Resolved
…ssive

The Containers SDK's 500 no longer marks a session active, so a reload during
a rollout loads the published document rather than showing an error. What a
visitor can see is the unsent gesture and a live sample that fails until Reset.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit bea58a2 into main Nov 19, 2026
6 checks passed
@max-sixty
max-sixty deleted the lighter-draft-dot branch November 19, 2026 07:14
max-sixty added a commit that referenced this pull request Nov 19, 2026
A leaf.page visitor's comments, choices, agent thread and revisions now
survive a deploy. The Worker named each visitor's private record and
container after the release, so every deploy pointed every visitor at an
empty record that started from the published page. Deploys came a median
of 28 minutes apart last week, and both real browsers that added
anything to a page lost it within 25 minutes. The record is now keyed by
the page protocol and the session store's own format
(`${protocol}.${STORE_FORMAT}`), so a deploy keeps it and only a bump of
either starts a visitor fresh, as a local page lasts across Leaf updates
at one protocol. A test pins each store format to a digest of its
tables, so a table change that leaves the format alone fails.

Making the record readable by the next release took these changes beyond
the key:

- **The record holds every revision it reads.** It used to leave out the
revisions the release published, but each build re-initializes every
page, so the next release's revision 1 is a different file. The manifest
now names each release's revision files (`revisions`), and only those
load from the release's static assets.
- **Saved responses are served only to the release that captured them**,
since a saved document names that release's assets. The first read under
a new release starts the container, which saves them again.
- **The first request after a deploy stops a container from before it**,
under the object's concurrency gate, so no request stops a container
this release is starting.
- **An active page's versions come from its own record.** Versions are
named by number, so the release's published `versions/v1.html` can be
another page than the visitor's.
- **An active session object resets at the deploy**
(`code_update_strategy = immediate` in `wrangler.toml`). By default
Cloudflare lets an object that keeps receiving requests run the previous
Worker version for up to five minutes. Keyed by protocol, the new edge
reaches that same object, which answers from the previous release's
records while the edge names the new release, so an open tab would
reload onto the old page at every answer.
- **A page's startup no longer holds its registry's headers to its
release.** The registry sits under the revision's assets path, named by
the bytes served there and cached by the browser for a year. A visitor's
record now keeps that path across a deploy that leaves the runtime
alone, so the browser answered the registry from its cache with the
previous release's `Leaf-Release`, and each reload reloaded again. The
initial state read, which the cache never answers, speaks for the
server.

Restoring also skips the record of a page that the new release dropped.

To weigh:
- During each rollout's few minutes, a visitor who has acted on a page
has their reads and sends retried until the new image answers, and a
reload then shows Cloudflare's "Failed to start container". Before, they
were already back on the published page.
- A page's first save in a session now uploads its published revisions
too, a few hundred KB.
- An agent turn cut off by a deploy still leaves its message unanswered
(#4080).

It builds on #6474, which has merged. The maintainer chose it on the
Leaf page, reversing #717's rule that a release never reads another
release's records. Codex reviewed it independently and found two cases,
a container destroyed while it started and versions served from the
static assets, which the second commit fixes; its review of the fix
found nothing. The leaf-agent review asked for the store format in the
key, which the third commit adds.

Trials on `leaf-website-dev` deployed this branch five times with an
active visitor, whose comment, agent reply and agent revision came back
under each new release. They found the cases the last two bullets fix:
the visitor's session object ran the previous Worker version for 4.5
minutes after a deploy (Workers Observability), and once the new release
answered, their open tab reloaded about ten times a second until closed.
With both fixes, the object ran the new version from a second after the
deploy, and the tab reloaded once at each of two deploys, one that
changed the runtime and one that didn't.

Tests: a restore test in which a page saved under one release keeps its
own revision 1 and comment under a release that publishes a different
revision 1 (it fails on the base), a store test, a container test,
manifest assertions in the site journey, and a runtime test in which a
registry cached from the previous release leaves the page alone (it
reloads on the parent commit). `pnpm run check` and
`tests/process/website_server` pass.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Nov 20, 2026
…frame

Review of the previous commit found its check-side half wrong at depth: a sample
inside a sample was skipped silently, only the window's scroll went back, a held
resize landed after the check returned, and the wait after each scroll stayed
open only because the scroll left rendering unsettled. Its page-side half was a
second watcher of the frame beside the host's own (`admitted`), exported as a
public `frameArrival` that only sample code called.

Behavior change: the sample host now counts its child document's whole arrival,
and `lf-sample` counts none of it. An allocation counts from when it begins until
its frame loads, wherever the frame stands. From the load, or a reload's
connection, until the child reports its arrival or departs, the host counts it
until the browser's first reading of the frame and then only while the user can
see the frame. The widget layer's upgrade waits on a rendering too: a hidden
child holding a chart stayed at readiness stage `upgraded` with two arrivals
outstanding, so counting through upgrade wherever the frame stands still stalled
the page. The `arrived` host notice is gone; the child still reports its arrival
to the host.

A check's `near-work` now answers once the child has started that work, and
`start_near_work` waits for each sample's own document instead: for every sample
frame at any depth whose readiness is not `ready`, outermost first, it scrolls the
frame into view with Playwright, waits for that frame's readiness, and puts back
every box holding the frame in each document; then it waits one rendering and for
the page. A frame in a closed disclosure or a shut tab is left as the page has it.

On the reviewer's pages: a chart sample two thousand pixels down inside another
sample draws and upgrades; a sample in a scrolling box leaves the box at 0; a held
block sample is at its final 846 px on return in 3 of 3 runs; a page with
`scroll-behavior: smooth` returns at 0. The extended hosting test covers the box,
the nested sample and the settled layout; with the scroll put-back disabled it
fails with the window at 3536 and the box at 1494. `page check --render` passes in
12 s on the incident page of three chart samples and on the skim-size decision page.

module-authoring.md also drops the host's `waiting` notice, removed in #6474.
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