Repository navigation
Guard public Leaf deployment capacity - #386
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The code revert and the PAGES binding read right, and the worker gate is green here (npm run typecheck clean, npm test 19 passed, uv run pytest tests/test_website_deployment.py 1 passed). Two things about the migration list, and one about the new test's floor.
The v2 migration looks already applied on the account, so deleting it is not the revert. wrangler deploy sends migrations with the script upload, and both post-#380 publish-site runs got past that step — 34094193513 and 34096665873 each printed Uploaded leaf-website with env.PAGES (LeafWebsiteSession) in the bindings table. A binding to a class no migration ever created is rejected at upload, so the namespace is currently named LeafWebsiteSession and the script's migration_tag is v2. The container step then failed against the existing application, name leaf-website-leafexamplesession id a033161d-…, which is the same namespace carried through the rename.
With v2 gone from the config, wrangler's getMigrationsToUpload finds the deployed tag absent from the list and takes the foundIndex === -1 branch — it warns "You may have already deleted it. Applying all available migrations to the script…" and sends old_tag: "v2", new_tag: "v1", steps: [{ new_sqlite_classes: ["LeafExampleSession"] }]. That re-runs the create-class step against an account where that name is now free, so either Cloudflare rejects it and publish-site stays red, or it creates a second, empty namespace: PAGES binds to that one while the standing container application stays attached to the old one, along with every seated reader session.
Keeping v2 and appending a v3 that renames back is correct under both readings — if the rename did apply, v3 undoes it; if it somehow did not, v2 then v3 apply back to back as a no-op. Either way the derived application name lands on leaf-website-leafexamplesession and the deploy takes the modify path. Inline suggestion on the migration block.
The new test would pass on the near-miss version of this fix. It compares the container class against the union of new_sqlite_classes without replaying renamed_classes, so a config with v2 retained and class_name = "LeafExampleSession" — the shape above, binding to a class the chain renamed away — passes. It also reads only new_sqlite_classes, so a future non-SQLite new_classes entry false-fails. Replaying the chain and asserting on the class it leaves standing is the invariant the docstring names; suggestion inline.
import tomllib breaks the project's declared floor. pyproject.toml says requires-python = ">=3.10", and tomllib is 3.11+, so on 3.10 this module fails to import and reddens the whole everyday suite at collection. The repo has already hit this — tests/test_interact_layer.py reads pyproject.toml off the lines rather than parsing it, and says why: "the project's own floor is 3.10, with no tomllib to parse with". Either raise the floor deliberately or read this config the same way; I haven't suggested one inline because which of those is right is a project call rather than a mechanical fix.
Overlap: #392 is mine and fixes the same red deploy from the other side — it pins name = "leaf-website-leafexamplesession" on [[containers]] and leaves the class renamed. This PR's direction is the better one once the migration chain is right, since it puts the code and the deployed identity back in agreement instead of pinning a name that lags the class; #392 should close if this lands. Separately, the instance ceiling #392 describes (max_instances = 10 with every product page now taking a seat) is underneath both and is not addressed by either.
Holding a verdict on the migration point rather than on style — a deploy that half-applies here costs the standing namespace, and I'd want that confirmed against the account before it runs.
# Conflicts: # worker/wrangler.toml
leaf-agent
left a comment
There was a problem hiding this comment.
Approving. The worker gate is green here — npm run typecheck clean, npm test 21 passed — and actionlint (shellcheck included) accepts the rewritten step. I checked the description's timing arithmetic and the test's derived application name against curl and wrangler themselves rather than taking them on trust; both hold.
One inline suggestion, on the half of the step that stays undiagnostic.
Overlap: #377 is mine and raises --max-time from 10 to 25 in this same step, and its "remaining risk" section is the max_instances = 10 ceiling this PR raises — it is fully superseded and should close once this lands.
What I verified
--max-time is per attempt, not per whole operation, so the budget arithmetic in the description holds: curl --retry 3 --retry-all-errors --retry-delay 1 --max-time 2 against a black-holed address takes 11s, not 2s. The two-probe worst case is 2 × (21 × 25 + 20 × 5) = 1250s ≈ 20.8 min, essentially where the old --retry 30 --retry-delay 10 --max-time 10 sat (20.3 min), so the 30-minute job timeout is no tighter than before.
--fail-with-body with --output does not accumulate across retries — curl truncates the file before each attempt, so cat "$response" prints the final body alone. Confirmed against a local server returning a distinct 500 body per attempt: the file held the third body, 10 bytes.
Wrangler derives the container application name as ${topLevelName}-${containerAppOptional.class_name} then .toLowerCase().replace(/ /g, "-"), so ${config.name}-${createdClass.toLowerCase()} reproduces it exactly for the no-environment case. Deleting the explicit name from [[containers]] now reddens the test rather than the deploy.
set -e propagation through the function is intact: simulating the step under bash -e, both a retry-exhausted 500 and a false predicate exit 1 without reaching the line after the call.
|
What is new is that the ceiling now takes the landing page with it, not just Repeated four times over ~90s across No fix PR from me — this PR already carries the remedy at the right level, and #377 stays superseded. |
Summary
Why
#392 restored deployment by explicitly naming the standing container application, safely decoupling that external identity from the renamed TypeScript class. Its rollout then exposed the next production boundary:
https://leaf.page/api/statereturnedMaximum number of running container instances exceededbecause the example-only ceiling of 10 now applies to every product-page reader. The verification job retried for ten minutes but discarded that response body, leaving only timeouts and opaque HTTP 500 lines in the log.The higher ceiling keeps a hard cost bound while allowing 100 concurrent private Leaf sessions. The new tests catch a lost application name, a container/binding mismatch, or a return to the example-only capacity in pull-request CI. Verification now allows 25 seconds per cold-start attempt, keeps the two-probe worst case below the 30-minute job timeout, and emits the final error body.
Testing
npm run typecheck --prefix workernpm test --prefix worker— 21 passeduv run pre-commit run --all-filesuv run scripts/site.pynpx wrangler deploy --dry-run --containers-rollout=none --outdir <temporary-directory>