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 天内回复

已经有一个关联 PR 被合并了。

  • #498 来自 @Brooooooklyn —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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
平均合并
11 小时 52 分钟
30 天内合并 PR
88

环境准备

这个项目没有提供开发容器、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 摘要。