Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Cloudflare deploy: framework prerender inside `void deploy`'s build deletes `.wrangler/deploy/config.json` (ENOENT)

未關閉 適合新手
#463 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

從 dist/index.mjs 中的 restorePreviewPointer 開始,並比較其 deploy-build guard 與 issue 中描述的 stash 端檢查。執行提供的雙 build 重現步驟,接著確認有 stash 時,deploy 模式建置後 .wrangler/deploy/config.json 仍然存在,同時手動預覽行為維持不變。

由索引模型根據 Issue 內容生成。

描述

Problem

In a TanStack Start app with voidPlugin() and TanStack's own build-time prerender (tanstackStart({ prerender: { enabled: true } })), void deploy fails after the build whenever an earlier plain vite build left a stashed pointer in .void/:

[prerender] Prerendered 4 pages:
...
◇ Preparing deployment...
■ ENOENT: no such file or directory, open '<root>/apps/web/.wrangler/deploy/config.json'

TanStack Start prerenders by starting a Vite preview server inside the build process. Void's plugin sees isPreview === true there and runs the preview restore path meant for a manual vite preview, including in the deploy build:

vite build              ── closeBundle: stash .wrangler/deploy/config.json → .void/preview-deploy-config.json
void deploy
  └ child build (VOID_CLOUDFLARE_DEPLOY_BUILD=1)
      ├ build writes a fresh .wrangler/deploy/config.json
      ├ prerender starts a Vite preview server
      │   └ config(): isPreview → restoreCloudflarePreviewPointer()
      │       ├ writes the stash from the earlier build over the pointer
      │       └ process.once("exit", rmSync(.wrangler/deploy/config.json))
      └ child exits → pointer deleted
  └ readGeneratedDeployConfig() → ENOENT

The stash side already skips deploy builds (closeBundle checks VOID_CLOUDFLARE_DEPLOY_BUILD !== "1"). The restore side has no such check (dist/index.mjs, restorePreviewPointer in voidPlugin).

This is the same pointer mechanism as #419, reached from the other direction. There a preview could not find the pointer. Here a preview inside a deploy build removes it.

Repro

A fresh clone reproduces it without void connect and without Cloudflare credentials. The deploy-mode build uses the env void deploy gives its build child.

git clone https://github.com/SweetRetry/void-starter && cd void-starter
git checkout 5230137
pnpm install
cd apps/web
pnpm exec vp build                                                  # plain build, stashes the pointer
VOID_CLOUDFLARE_DEPLOY_BUILD=1 NODE_ENV=production pnpm exec vp build   # what void deploy runs
ls .wrangler/deploy/config.json                                     # missing

Prerender is configured in apps/web/vite.config.ts. The repo's deploy script works around the bug by deleting .void/preview-deploy-config.json first, so call vp build directly as above.

Controls, each starting from an empty .wrangler/deploy and .void/preview-deploy-config.json:

Case Stash before deploy build Prerender Pointer after deploy build
A present on missing
B deleted on present
C present off present

An exit listener registered through NODE_OPTIONS=--require (so it runs before Void's) saw the pointer present in case A. The outer processes then saw it missing, so it is removed by the exit cleanup.

Suggested fix

Skip the restore in deploy builds, the same check the stash side already has:

 const restorePreviewPointer = () => {
   if (!existsSync(join(root, "void.config.ts"))) return;
+  if (process.env["VOID_CLOUDFLARE_DEPLOY_BUILD"] === "1") return;
   if (restoreCloudflarePreviewPointer(root) && !scheduledPreviewPointerCleanups.has(root)) {

With this patch applied to dist/index.mjs, case A keeps .wrangler/deploy/config.json ({"configPath":"../../dist/server/wrangler.json"}) after the deploy-mode build. A manual vite preview still finds the build output and gets as far as the remote binding session, which then fails only for lack of an API token in a non-interactive shell. That path runs without the env var, so its code is unchanged.

An alternative is for void deploy to remove .void/preview-deploy-config.json before it starts the build. That is the current workaround.

Question

The framework docs describe routing.prerender (deploy-time edge prerendering) for framework mode and don't mention a framework's own build-time prerender. Is TanStack Start's prerender option a supported setup with Void? We chose it so the blog pages ship as static assets in dist/client and a prerender failure fails the build.

Environment

  • void 1.1.11
  • @tanstack/react-start 1.169.2
  • @cloudflare/vite-plugin 1.64.0, wrangler 4.151.0
  • vite-plus 1.3.0
  • Node 24.14.1, pnpm 12.0.0, macOS
主要語言
TypeScript
星號
402
分支
32
平均合併
12 小時 28 分鐘
30 天內合併 PR
77

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

voidzero-dev/void 的其他 Issue

查看 voidzero-dev/void 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。