Skip to content

Astro: astro preview fails after astro build in Void apps, and dev restarts can drop the trigger middleware #419

Closed

Description

@Brooooooklyn

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.ts and the Cloudflare adapter: astro build, then astro preview.
  • b. Delete .astro/, run astro dev outside CI, and watch for "Configuration file updated. Restarting..." right after "ready".
  • c. After (b), check whether src/middleware.ts still exists, and POST to /__void/scheduled with the dev trigger token.

Cause

  • a. packages/void/src/index.ts:125-143: for Astro, closeBundle schedules the pointer move on process exit (:132-136). The restore runs only in the plugin's config hook in preview (:114-123). @astrojs/cloudflare 14.3.4 dist/entrypoints/preview.js:21-25 checks the pointer before it calls Vite's preview() with configFile: false. Same code on main.
  • b. Astro 7.3.7 dist/core/dev/update-check.js (12-day interval, ASTRO_DISABLE_UPDATE_CHECK) and dist/core/dev/restart.js:34-36 (one-time ignore flag).
  • c. packages/void/src/plugin-framework-triggers.ts:577-608: ensureFile warns when the file exists (:580), and cleanup removes the file only in the instance that wrote it, on httpServer close (:607). Vite's restartServer creates 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 preview runs, for example an Astro integration hook.
  • b. Report upstream. Optionally mention ASTRO_DISABLE_UPDATE_CHECK=true in 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

🤖 Generated with Claude Code

https://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH

Activity

  1. added 5 commits that reference this issue on Oct 14, 2026
    86495f9
    04fa86d
    763b856
    d963d20
    ee0267b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions