Cron handlers resolve void/env to its browser build in Cloudflare deploys
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript, vite
- 領域
- build-system
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 627
- 分支
- 66
- 平均合併
- 14 小時 17 分鐘
- 30 天內合併 PR
- 200
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/void 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 55/100
voidzero-dev/void#718 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 28/100
voidzero-dev/void#692 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 30/100
voidzero-dev/void#689 ·
維護者通常 1 天內回覆
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for files未關閉
難度 4/5 3-5 天 新手友好度 35/100
voidzero-dev/void#679 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 18/100
voidzero-dev/void#661 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
vercel-labs/durable-harness#53 ·
維護者通常 1 天內回覆
-
[Bug]: Redesign tab bars ignore clicks on Linux: hidden chat layers keep window drag regions可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
experiência: a doc manda subir para o Micro do Supabase, mas não diz que exige plano pago nem quanto custa可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉area/docs area/ui enhancement
難度 1/5 1-3 小時 新手友好度 88/100
melgarafael/DeskcommCRM#4098 ·
維護者通常 1 天內回覆
-
bug ready-for-agent
難度 2/5 1-3 小時 新手友好度 86/100
kerti/balances-v2#801 ·
維護者通常 1 天內回覆
-
lesson-submission pending-review
難度 1/5 1 小時以內 新手友好度 84/100
Ikalus1988/MisakaNet#4510 ·
維護者通常 1 天內回覆