Repository navigation
Astro: astro preview fails after astro build in Void apps, and dev restarts can drop the trigger middleware #419
Description
Problem
a. astro preview cannot find the build
In an Astro app with void.config.ts:
astro build
astro preview[ERROR] [@astrojs/cloudflare] No build output found. Run `astro build` before running `astro preview`.
The build did write its output. On exit, Void moves Wrangler's deploy pointer .wrangler/deploy/config.json to .void/. Void puts it back only when its own Vite plugin runs in preview. Astro's adapter checks the pointer first, and it starts its preview server with configFile: false, so Void's plugin never runs there.
astro build ── closeBundle ── on exit: move .wrangler/deploy/config.json to .void/
astro preview ── adapter: existsSync(.wrangler/deploy/config.json)? no ── "No build output found"
(Void's restore runs only in a Vite preview that loads Void's plugin)
Workaround: run the build with VOID_CLOUDFLARE_DEPLOY_BUILD=1. Void's own Astro integration test does this.
b. Astro's update check restarts astro dev right after "ready" (upstream)
When Astro's update check is due (a fresh .astro/ folder, or 12 days since the last check, and not in CI), astro dev restarts itself just after it prints "ready":
astro v7.3.7 ready in 3531 ms
...
03:01:28 Configuration file updated. Restarting...
The check writes .astro/settings.json. The file watcher reports an add and a change, and Astro's one-time "ignore the next preferences reload" flag covers only the first. A request during the restart fails. This is an Astro bug, not a Void bug. Workaround: ASTRO_DISABLE_UPDATE_CHECK=true.
c. After a dev restart, the dev trigger middleware may be removed (unverified)
After the restart in (b), Void logged:
[void] Astro middleware already exists. To enable /__void/scheduled and /__void/queue,
add the Void dev-trigger middleware to your existing onRequest sequence.
Void had written src/middleware.ts itself at the first start. The new plugin instance sees that file, warns, and does not take ownership. The old instance removes the file when its server closes. If that happens, /__void/scheduled and /__void/queue stop working until astro dev restarts. Only the warning was seen; the removal was not checked.
Repro
- a. Astro app with
void.config.tsand the Cloudflare adapter:astro build, thenastro preview. - b. Delete
.astro/, runastro devoutside CI, and watch for "Configuration file updated. Restarting..." right after "ready". - c. After (b), check whether
src/middleware.tsstill exists, and POST to/__void/scheduledwith the dev trigger token.
Cause
- a.
packages/void/src/index.ts:125-143: for Astro,closeBundleschedules the pointer move on process exit (:132-136). The restore runs only in the plugin'sconfighook in preview (:114-123).@astrojs/cloudflare14.3.4dist/entrypoints/preview.js:21-25checks the pointer before it calls Vite'spreview()withconfigFile: false. Same code on main. - b. Astro 7.3.7
dist/core/dev/update-check.js(12-day interval,ASTRO_DISABLE_UPDATE_CHECK) anddist/core/dev/restart.js:34-36(one-time ignore flag). - c.
packages/void/src/plugin-framework-triggers.ts:577-608:ensureFilewarns when the file exists (:580), andcleanupremoves the file only in the instance that wrote it, onhttpServerclose (:607). Vite'srestartServercreates the new server, then closes the old one. Same code on main.
Suggested fix
- a. Do not move the pointer after an Astro build. Or restore it from a hook that
astro previewruns, for example an Astro integration hook. - b. Report upstream. Optionally mention
ASTRO_DISABLE_UPDATE_CHECK=truein the Astro troubleshooting docs. - c. Make the middleware file's ownership survive a restart, for example mark the file Void wrote with a header comment and treat a marked file as Void's own. First check that the removal happens.
Evidence
- a. Seen in a run of the Astro build-and-preview integration test that fix(void): make PostgreSQL and MySQL void/db work across frameworks, builds and deploys #413 adds, before the test set
VOID_CLOUDFLARE_DEPLOY_BUILD=1. Code read at main and the head of fix(void): make PostgreSQL and MySQL void/db work across frameworks, builds and deploys #413. - b. Seen in a dev log:
.astro/settings.jsonreported asaddthenchange, then the restart. Astro source read. - c. Only the warning was seen in the same log. The removal is not verified.
- Not changed by fix(void): make PostgreSQL and MySQL void/db work across frameworks, builds and deploys #413.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(void): give framework dev crons the handler exports of bare void,…
fix(void): give framework dev crons the handler exports of bare void,…
fix(void): give framework dev crons the handler exports of bare void,…
fix(void): give framework dev crons the handler exports of bare void,…
fix(void): give framework dev crons the handler exports of bare void,…