Skip to content

Name the standing container application so the Durable Object class rename modifies it - #392

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-34094193513
Sep 7, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-34094193513

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Problem

publish-site went red on main at run 34094193513. The worker version uploaded fine; wrangler deploy then failed applying the container application:

✘ [ERROR] Error creating application due to a misconfiguration:

  DURABLE_OBJECT_ALREADY_HAS_APPLICATION
  name leaf-website-leafexamplesession
  id a033161d-5237-468e-a177-b27b3c5d27dd

#380's v2 migration renamed the Durable Object class LeafExampleSession → LeafWebsiteSession, which preserves the namespace but changes the name wrangler derives for the container application. Wrangler looks the deployed application up by name and creates a new one when the lookup misses, so it asked Cloudflare for a second application against a namespace that already holds one — and a namespace can hold only one. The deploy log shows it taking that branch: NEW leaf-website-leafwebsitesession against durable_objects.namespace_id = "1dd7cf01600744e19eda64939aaf932d", the namespace the rename carried over.

This is durable, not a capacity blip: every publish-site run since #380 hits the same wall, because the rename is in the config each of them reads.

Solution

Name the standing application in [[containers]]. That is the one knob wrangler consults before deriving a name, so the lookup hits leaf-website-leafexamplesession, the deploy takes the modify-and-roll-out path, and the container picks up the image the run just built. The comment beside it records why the name lags the class: renaming an application means deleting the existing one first, which drops every seated reader session, so it is a maintainer's call rather than a deploy-time one.

The site is serving 500s, and this fix alone will not settle that

Independent of the deploy, https://leaf.page/ currently answers Failed to start container: Maximum number of running container instances exceeded — three fresh-cookie probes at 07:33 and 07:37 UTC, each ~11.5s. #380 routed every product page through the container, so the homepage now takes a seat per reader against max_instances = 10 with sleepAfter = "10m"; before it, only /examples/<slug> did. This PR unblocks the rollout, which will recycle the held instances, but the ceiling underneath is the same one #377 measured and left for a maintainer to weigh.

Testing

Evidence

Wrangler's own lookup, from worker/node_modules/wrangler/wrangler-dist/cli.js — by name, with the derived name only as a fallback:

const application = applicationByNames[appConfigNoDefaults.name ??
`${config2.name}-${appConfigNoDefaults.class_name}`];

A hit takes the modify branch with id: application.id; a miss takes NEW, which is what the failed run printed.

The name now resolves to the standing application, read back out of a dry run (no Docker in this environment, so the container rollout is skipped):

$ npx wrangler deploy --dry-run --outdir /tmp/wrangler-dry --containers-rollout=none
The following containers are available:
- leaf-website-leafexamplesession (/home/runner/work/leaf/leaf/Dockerfile.website)

Live probes, three fresh sessions:

code:500 time:11.430604
code:500 time:11.570158   Failed to start container: Maximum number of running container instances exceeded
code:500 time:11.562378   Failed to start container: Maximum number of running container instances exceeded

The worker gate passes: npm run typecheck clean, npm test 19 passed. python3 -m tomllib parses the config. publish-site runs only on pushes to main, so this branch's CI cannot exercise the changed deploy; merging it re-runs the workflow, since worker/** is in its trigger paths.


Automated fix for failed run

@max-sixty
max-sixty enabled auto-merge (squash) September 7, 2026 07:49
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

publish-site failed again on main with the same wall this PR fixes: run 34096665873, on f873d5aa ("Add reset mode to preview command (#381)"), which touches nothing in worker/. The deploy step printed the identical error, down to the application id:

├ NEW leaf-website-leafwebsitesession
│   [containers.durable_objects]
│   namespace_id = "1dd7cf01600744e19eda64939aaf932d"

✘ [ERROR] Error creating application due to a misconfiguration:

  DURABLE_OBJECT_ALREADY_HAS_APPLICATION
  name leaf-website-leafexamplesession
  id a033161d-5237-468e-a177-b27b3c5d27dd

That is the second consecutive failure and confirms the durable-cause reading in the PR body — the run before it, 34094193513, was the first after #380 landed, and every run since reads the same worker/wrangler.toml. origin/main still has [[containers]] with no name, so wrangler keeps deriving leaf-website-leafwebsitesession and taking the create branch. No fix landed on main in the meantime, and no separate PR covers it, so I'm not opening a second one.

Run history

publish-site on main, newest first:

34096665873  07:40  f873d5aa  failure    Add reset mode to preview command (#381)
34096007294  07:32  821e0d5b  cancelled  Fix interaction gallery startup (#378)
34094193513  07:10  14c746ba  failure    Serve product site as live Leaf pages (#380)
34090316235  06:19  6b77b0a9  success    Filter go-to targets by kind (#376)

#380 is the commit that introduced the v2 rename; the last green run predates it.

@max-sixty
max-sixty merged commit 8cb5fb8 into main Sep 7, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-34094193513 branch September 7, 2026 07:57
max-sixty added a commit that referenced this pull request Sep 7, 2026
## Summary

- raise the public Leaf container ceiling from 10 to 100 concurrent
private sessions
- add deployment-config tests that pin the explicit Cloudflare
application identity, align the container and Durable Object binding
classes, and retain the public-session capacity floor
- run those guards in the Worker-specific pull-request gate using the
same TOML parser Wrangler uses
- make post-deploy verification tolerate a realistic cold start, stay
within the job budget, and print Cloudflare response bodies on failure

## 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/state` returned `Maximum number of running
container instances exceeded` because 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 worker`
- `npm test --prefix worker` — 21 passed
- `uv run pre-commit run --all-files`
- `uv run scripts/site.py`
- `npx wrangler deploy --dry-run --containers-rollout=none --outdir
<temporary-directory>`
- local execution of the verification curl/jq path against the live
preview

> _This was written by Codex on behalf of max-sixty_
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