Cron handlers resolve void/env to its browser build in Cloudflare deploys
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript, vite
- Ambito
- build-system
Direzione di ricerca
Read the deploy wrapper code in dist/wrapper-*.mjs, especially the block that writes .void/handlers/handlers.ts and runs Vite build(), then inspect .void/handlers/out/__void_handlers.js after deployment. Confirm which export of void/env the handler bundle resolves and compare it with the Worker build. Done when deployed cron and queue handlers can read server environment keys, while the existing development and Vitest behavior still works.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
In a deployed Cloudflare Worker, a cron job that reads a server value through void/env throws:
env: Key 'FOO' is not exposed to the client. Void only exposes VITE_* schema keys to browser code. Either rename the key in env.ts with that prefix, or move this access to a server module.
The same code works under void dev (POST /__void/scheduled) and in Vitest with @cloudflare/vitest-pool-workers, so tests do not catch it. Request handlers in the same Worker read the same key without trouble.
Versions: void 1.3.0 with @tanstack/react-start 1.169.4, D1, direct Cloudflare deploy (void deploy --platform cloudflare). The handler bundling code below is unchanged in 1.6.1.
Reproduce
-
env.ts:export default defineEnv({ FOO: z.string() }), and setFOOas a Worker secret. -
crons/foo.ts:import { defineScheduled } from "void"; import { env } from "void/env"; export const cron = "0 * * * *"; export default defineScheduled(async () => { console.log(env.FOO); }); -
Deploy, then let the schedule fire, or call
POST /__void/scheduledwith aCRON_SECRET. The run fails with the error above; the HTTP route returns{"error":"AggregateError: Scheduled jobs failed"}.
Likely cause
The deploy wrapper bundles cron and queue handlers separately (.void/handlers/handlers.ts → .void/handlers/out/__void_handlers.js) with Vite's build() in library mode (dist/wrapper-*.mjs, the block that writes handlers.ts). That build sets no ssr option or resolve conditions, so Vite resolves packages with its default client conditions. void/env's browser export wins, and the bundle inlines dist/runtime/env-public-client.mjs instead of the workerd/worker build, env-public.mjs. The generated bundle contains the client module's "is not exposed to the client" message.
Queue consumers go through the same handler bundle, so they are probably affected too.
Possible fix
Build the handlers bundle with Worker resolve conditions (for example resolve.conditions: ["workerd", "worker", "import", "module", "default"], or as an SSR build targeting webworker). Or alias void/env to the server build, as the build already aliases void to void/handler.
Workaround
In code that cron jobs run, read values from the Worker's bindings with import { env } from "cloudflare:workers", validated with the same schema.
- Lingua principale
- TypeScript
- Stelle
- 627
- Fork
- 66
- Merge medio
- 14h 17m
- PR unite (30g)
- 200
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di voidzero-dev/void
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
voidzero-dev/void#718 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
voidzero-dev/void#692 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
voidzero-dev/void#689 ·
I maintainer di solito rispondono entro 1 giorno
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
voidzero-dev/void#679 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
voidzero-dev/void#661 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di voidzero-dev/void
Issue simili
-
unwrapDatabaseError masks real DB errors with TypeError: Cannot convert object to primitive valueAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
NEARBuilders/everything-dev#798 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vercel-labs/durable-harness#53 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Redesign tab bars ignore clicks on Linux: hidden chat layers keep window drag regionsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
experiência: a doc manda subir para o Micro do Supabase, mas não diz que exige plano pago nem quanto custaForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea/docs area/ui enhancement
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
melgarafael/DeskcommCRM#4098 ·
I maintainer di solito rispondono entro 1 giorno
-
dependencies platform: ios
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
software-mansion/react-native-executorch#1617 ·
I maintainer di solito rispondono entro 1 giorno