Skip to content

Read saved site state before verify-site opens a thread, since a text box's focus now starts the container - #5810

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-5809
Nov 10, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-5809

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

publish-site on main has failed since #5802 (run 42904167365, RuntimeError: private revision resource woke its container). #5802 made the Worker start a visitor's container (prewarmContainer) when an interaction batch reports a text box's focus. verify_saved_state in leaf-dev verify-site clicks the saved thread, which focuses its reply leaf-text, and only after that checks that the state, the revision stylesheet and the revision document came from durable storage. The run's log shows the sequence: a focusin on leaf-text with textBox: true, then container_prewarm_completed, then the stylesheet GET taking 4 s and being answered by the woken container.

This PR moves the thread step to the end, after every durable read, the "reading saved content started a page container" comparison and the media write. Each of those checks again finds the container stopped: the reads still prove they are served from durable storage, and the write still proves it wakes the container and that the next writer restores the record. The thread's saved comment and the browser-error check still run, after the thread opens. Nothing changes in the Worker, the runtime or the prewarm.

Verification: this PR's ci runs uv run leaf-dev verify-site website-worker ("Measure the bundled release in a browser"), the same command as the failing step. The failing run above is the before.

For the author of #5802 to weigh: opening a thread puts focus in its reply box, so every thread open on leaf.page now starts the session's container, even when the visitor only reads. The rate limit bounds this. Whether that counts as "about to write" is a product call, and this PR doesn't make it.

Refs #5809 — automated triage

… box's focus now starts the container

#5802 made the Worker start a visitor's container when an interaction batch
reports a text box's focus. verify-site's saved-state check opened the saved
thread, which focuses its reply box, and only then asserted that the state,
revision stylesheet and revision document came from durable storage. The
prewarm woke the container in between, so the stylesheet read was served by
the container and publish-site failed with "private revision resource woke its
container" (run 42904167365). The check now does every durable read and the
running-container comparison before opening the thread. The prewarm and what
the site serves are unchanged.

Refs #5809

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening the thread now happens before the media write, so the container is already running when the media POST goes out. The later check(worker.containers() != asleep, "the mutation did not wake the container") therefore passes because of the prewarm, not because of the write. The verifier no longer shows that a write wakes a stopped container. I'll push a fix that moves the thread step after that check. The comment check still runs, and the media write runs with the container asleep again.

Comment thread dev/leaf_dev/commands/verify_site.py Resolved
…till wakes a stopped container

Opening the thread focuses its reply box, which starts the container. Placed
before the media write, it left "the mutation did not wake the container"
passing on that prewarm rather than on the write. The thread step and the
browser-error check now come after the write's checks.

Refs #5809
@max-sixty
max-sixty merged commit 37de78c into main Nov 10, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-5809 branch November 10, 2026 21:56
leaf-agent added a commit that referenced this pull request Nov 10, 2026
…5815)

A leaf.page read that hits a dropped container connection now gets one
more attempt in the Worker instead of reaching the visitor as a 500.
This is the failure behind `publish-site`'s red run on `37de78c5458c`
([run
42909821856](https://github.com/max-sixty/leaf/actions/runs/42909821856)):
the open page's `/api/news` poll landed while the verifier's media
upload was waking the container, the SDK answered `500 Error proxying
request to container: Error: Container port connection closed
unexpectedly.`, and the saved-state browser-error gate counted the
console error. #5810 had just moved that gate behind the media write.

**Cause.** Containers SDK 0.3.7 catches a proxy failure and returns a
plain 500 with one of two bodies: `Container suddenly disconnected, try
again` or `Error proxying request to container: …`
(`dist/lib/container.js`, the `catch` in `containerFetch`).
`LeafWebsiteSession.forward` logged that 500 and returned it unchanged.
The same shape (one `/api/news` or `/api/state` 500 at the
Worker-to-container boundary, then a successful read) was written off as
transient in #2331, #3115 and #3165.

**Change.** `forward` classifies both SDK bodies as `disconnected`. It
sends a `disconnected` `GET` or `HEAD` once more and returns the second
answer. A write is never resent, because it may already have reached
Python. A 500 that Python stamped with `Leaf-Release`, or any other
unclassified 500, passes through as before. The `http_error` record
gains `retried`, and `worker/README.md` documents it.

**Verification.** The new Worker test (`reads again once when the
container connection drops, but never resends a write`) fails on `main`
with `expected 500 to be 200` and passes here. `pnpm run check:worker`
passes (92 tests plus `tsc`). The start-up race needs Docker, which this
sandbox doesn't have (#4293), so the real check is the next
`publish-site` run, which goes through a container start in the
saved-state step.

Closes #5814 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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