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

Cloudflare deploy fails after adding a custom domain: generated comment is parsed as JSON

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

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

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

研究方向

閱讀packages/void/src/cli/cf-build-output.ts以及generated-wrangler-config.ts中現有的輔助函式readGeneratedWranglerConfigFile。檢查 issue 中提到的三處設定讀取,接著使用包含已發布流量快照的void.lock.json註解重現問題。當部署準備程序接受 JSONC 註解並保留自訂網域時,即為完成;issue 回報了本機的解決方法,但沒有上傳部署。

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

描述

void deploy fails after adding a Cloudflare custom domain. Void saves a comment in the generated configuration, then tries to read that file with JSON.parse.

Steps to reproduce

  1. Deploy an Astro app to your own Cloudflare account with pnpm exec void deploy.
  2. Attach a domain in that account with pnpm exec void domain add example.com.
  3. Commit the updated void.lock.json.
  4. Run pnpm exec void deploy again, including from a fresh CI checkout.

The build completes, but deployment stops at:

◇ Preparing deployment...
■ Unexpected token '/', "// void:pu"... is not valid JSON

The expected result is a successful deployment with the custom domain preserved.

Cause

The domain command saves a published-traffic snapshot as a comment:

// void:published-traffic:v1:...

That comment is saved in void.lock.json's text field and restored into .void-wrangler.jsonc. The file is valid JSONC, which allows comments, but not strict JSON.

prepareCfFrameworkBuildOutput reads the file with JSON.parse. The same file also uses JSON.parse in prepareCfStaticBuildOutput and the legacy path of prepareCfBuildOutput.

Local workaround

I patched those three reads to use the existing readGeneratedWranglerConfigFile helper from generated-wrangler-config.ts. That helper already handles comments and rejects invalid input.

I reproduced the original parsing error locally. With the patch, the same Worker preparation step accepts the comment and produces deployment output. This check did not upload the Worker. A frozen-lockfile install also succeeds with the pnpm patch.

Versions

  • Void: 1.1.11
  • Astro: 7.4.0
  • @astrojs/cloudflare: 14.4.0
  • Failing CI environment: GitHub Actions, Linux, Node.js 24.21.0

The JSON.parse calls are also present on main at 43c7fe17e402d4509516796eec3e7c832a2b0630.

主要語言
TypeScript
星號
402
分支
32
平均合併
12 小時 1 分鐘
30 天內合併 PR
80

環境準備

這個專案沒有提供開發容器、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 摘要。