You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Workers built by Astro 7.4.13 fail at startup: workerd-prelude's top-level await forms a chunk cycle with zod #392
When try.cloudhal.com is built with Astro 7.4.13 (instead of 7.4.7), its Worker fails at startup with:
Uncaught Error: Top-level await in module is unsettled.
wrangler deploy --dry-run passes. Only a real start fails: wrangler dev, or a deploy. Because of this, try#13 (the move to 0.12.0) keeps astro at 7.4.7.
cloudhal.com runs Astro 7.4.13 without the problem. Its Worker entries come from cloudhal deploy. In try, the Astro / Cloudflare Vite plugin build bundles the entry (src/playground/worker.ts).
Why
@cloudhal/cloudflare/workerd-prelude (packages/cloudflare/src/workerd-prelude.ts) runs const z = await import("zod/v4") at top level. That is the esbuild workaround from ADR-0012. With Astro 7.4.13:
Rollup inlines the prelude into the worker-entry_*.mjs chunk.
zod/v4 goes into its own v4_*.mjs chunk.
That chunk statically imports ./worker-entry_*.mjs back.
So the entry's top-level await waits for a module that waits for the entry, and never settles.
Whether a Vite/Rollup-built Worker needs the prelude at all. The esbuild ordering bug it works around is wrangler's bundler. If not, try (and any Astro-bundled entry) drops the import, and the prelude docs say it is for wrangler-bundled entries only.
If it is needed: a form without the top-level await cycle, for example a static import, checked against the original "ZodLazy is not a constructor" failure under wrangler's esbuild.
A start check, not only a dry run: the try deploy and the template check should start the built Worker once (for example wrangler dev and one request) before they pass.
Done when
try runs Astro ≥ 7.4.13 and starts.
The admin Worker that cloudhal deploy generates still starts.
That v4_*.mjs facade chunk starts with import "./worker-entry_*.mjs";.
With import "@cloudhal/cloudflare/workerd-prelude" removed from src/playground/worker.ts: the Worker starts. Every result is the expected playground answer, and there was no ZodLazy or other startup error:
Request
Result
landing
200
POST /_playground/session
303 → /sites
/api/sites
lists "Playground Notes"
/api/auth/*
403 (no sign-in in a playground)
/mcp
the playground's "not available" block
The esbuild ordering bug the prelude works around does not apply to Rollup output, so a Vite/Astro-bundled entry does not need the prelude.
Proposed fix
try: drop the prelude import and move to Astro 7.4.13.
Here: make the prelude doc comment and ADR-0012 say it is only for entries that wrangler bundles with esbuild (the cloudhal deploy admin entry). Optionally, the try deploy could start the built Worker once before deploying.
Fixed: cloudhal-dev/try#14 dropped the prelude import and moved try to Astro 7.4.13. It is deployed (version 348fa06a); the live smoke passed for landing, session, Studio, API, the visitor site, RSS and reset. #393 documents that the prelude is for esbuild-bundled entries only.
Activity
Madraka commentedon Dec 2, 2026
Local check (2026-12-03)
I built try
mainwith Astro 7.4.13 (Vite 8.3.8 override,@cloudflare/vite-plugin1.70.2) and started it withwrangler dev.With the prelude import: the Worker fails at startup with
Uncaught Error: Top-level await in module is unsettled. The build output shows the cycle:worker-entry_*.mjscontainsawait import("./v4_*.mjs").v4_*.mjsfacade chunk starts withimport "./worker-entry_*.mjs";.With
import "@cloudhal/cloudflare/workerd-prelude"removed fromsrc/playground/worker.ts: the Worker starts. Every result is the expected playground answer, and there was noZodLazyor other startup error:POST /_playground/session/sites/api/sites/api/auth/*/mcpThe esbuild ordering bug the prelude works around does not apply to Rollup output, so a Vite/Astro-bundled entry does not need the prelude.
Proposed fix
cloudhal deployadmin entry). Optionally, the try deploy could start the built Worker once before deploying.🤖 Generated with Claude Code
Madraka commentedon Dec 2, 2026
Fixed: cloudhal-dev/try#14 dropped the prelude import and moved try to Astro 7.4.13. It is deployed (version 348fa06a); the live smoke passed for landing, session, Studio, API, the visitor site, RSS and reset. #393 documents that the prelude is for esbuild-bundled entries only.