Repository navigation
fix(deploy): keep SvelteKit job bundles out of uploaded assets - #737
Merged
cpojer merged 1 commit intoNov 7, 2026
Merged
Conversation
SvelteKit's Worker directory is also its asset directory, so a native deploy lists the files Void adds there in `.assetsignore`. The list named the cron and queue bundle `__void_handlers.mjs`, but in an ES module package, which is what `sv create` makes, Vite names it `__void_handlers.js`, so the compiled job code was uploaded with the static assets. SvelteKit's Worker runs first and does not serve it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpojer
pushed a commit
that referenced
this pull request
Nov 12, 2026
…#804) Closes #794 `void deploy --platform cloudflare` writes `assets.run_worker_first: true` for SvelteKit, Nuxt, Analog, and Astro. Every request starts the Worker, including fingerprinted build files (`/_astro/*`, `/_app/immutable/*`, `/_nuxt/*`) and prerendered pages, and each one counts as a Worker request. The framework Worker only passes those requests to `ASSETS`. The write also replaces a `run_worker_first` set in `cloudflare.assets` in `void.config.ts`, although `docs/reference/config.md` says Void passes `cloudflare` fields through. Each framework's own Cloudflare config, and managed framework deploys, leave `run_worker_first` unset, so Cloudflare serves files without starting the Worker. ## Fix Without a `run_worker_first` in `void.config.ts`, framework deploys now write `["/__void", "/__void/*"]`: ``` request ──► Workers Static Assets │ ├─ /__void, /__void/* ──► Worker ├─ file matches ─────────► served, no Worker └─ no file ──────────────► Worker (not_found_handling: none) ``` - Server-rendered pages and endpoints have no file, so they still reach the Worker. Void's readiness, job, and queue endpoints always do. - A `run_worker_first` set in `void.config.ts` is written as is. `true` keeps the previous routing. - The setting is read from `void.config.ts`, not from the generated config. `void.lock.json` can hold the `true` an earlier deploy wrote, and the generated config is restored from it. - `writeCloudflareFrameworkDeployConfig` in `@void/deploy-cloudflare` takes an optional `runWorkerFirst`. It still defaults to `true`. - `docs/guide/edge/static-assets.md` describes the default and the setting. Running the Worker first gave these files nothing extra: - Void's framework wrapper handles only `/__void/*` and HTML document ISR. - The framework Workers pass static files and prerendered pages to `ASSETS` before rendering, so hooks and middleware do not run for them: SvelteKit's adapter Worker, Astro's (`matchStaticAsset`), and Nitro's `cloudflare-module` preset (`isPublicAssetURL`). A missing file still reaches the Worker, which answers as before. ### SvelteKit's asset directory SvelteKit uploads its Worker directory as its assets. With `true`, its Worker answered only its own files, so a module Void left there was stored but not served (#737). Cloudflare now serves any uploaded file from that directory, so `.assetsignore` must list every module Void adds. A comment at that list says so. The test that checks SvelteKit's uploaded files now enables ISR, so it covers `__void_isr.mjs` as well. ### Projects deployed with v0.20 v0.20 wrote `run_worker_first: true` into the root `wrangler.jsonc`, and the migration to `void.config.ts` copied it into `cloudflare.assets`. Those projects keep `true` until they remove that line. ## Tests - `packages/deploy-cloudflare/test/unit/framework.test.ts`: a given `run_worker_first` (a rule list, or `false`) replaces an earlier `true`, and writing it again changes nothing. - `packages/void/test/unit/cloudflare-deploy.test.ts`: - The SvelteKit case expects the new default. - An Astro project whose `void.lock.json` kept an earlier `true` gets the default. - `["/api/*"]`, `true`, and `false` set in `void.config.ts` are written as is. - The SvelteKit asset case enables ISR, so `__void_isr.mjs` must stay out of the upload too. Without this fix, the default, lock, `["/api/*"]`, and `false` cases fail with `run_worker_first: true`. ## Verification - `vp run test` (all 794 files): 793 pass, 1 skipped (16,695 tests pass, 30 skipped). - `vp run check`: 33/33 pass. - Miniflare, with a Worker that stands in for a wrapped framework Worker and marks its responses, and an `/_astro/*` immutable rule in `_headers`: - With `true`, `/_astro/app.abc123.js`, `/`, `/about/`, `/smoke`, and `/__void/ready` all start the Worker. - With the new rule, the file and the two prerendered pages are served without it, with the same status, `Cache-Control`, and body. `/smoke` renders in the Worker, and `/__void/ready` answers `{"ready":true}`. - Not run: `void deploy` against Cloudflare. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
void deploy --platform cloudflareuploads a SvelteKit Worker's directory as its static assets, so it lists the files Void adds there in.assetsignore. The list names the cron and queue bundle__void_handlers.mjs, but in an ES module package, which is whatsv createmakes, Vite names it__void_handlers.js. The compiled job code is then uploaded with the static assets.With the config this deploy writes (
run_worker_first: true), SvelteKit's Worker answers/__void_handlers.jswith a 404, because it serves only its own static files fromASSETS. The file is still stored with the deployment's assets, and would be served if the Worker no longer ran first.Fix
.assetsignorelists both__void_handlers.jsand__void_handlers.mjs, as it already does for__original.jsand__original.mjs.Tests
packages/void/test/unit/cloudflare-deploy.test.ts: prepares an ES module SvelteKit app with a cron job and checks that.assetsignorematches every file Void adds to the Worker directory, so only the app's own assets remain. The case fails without this fix.Verification
vp test run: 781 files pass, 1 skipped (16,160 tests pass, 29 skipped).vp run check: 33/33 pass.heartbeatcron makes Void add__void_handlers.js: build,prepareCloudflareFrameworkArtifact, thenprepareCfFrameworkBuildOutput. Without this fix, the upload's assets include__void_handlers.js; with it, they don't. Served by Miniflare with those assets,/__void_handlers.jsanswers 404 withrun_worker_first: trueeither way. Withrun_worker_first: false, it answers 200 with the job code without this fix, and 404 with it.void deployagainst Cloudflare.🤖 Generated with Claude Code