[Bug]: `theme dev` proxy 502s on cookie-heavy storefront responses (undici default 16 KiB `maxHeaderSize`)
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
Start by tracing the theme dev storefront proxy path that forwards requests and handles upstream fetch errors; the report does not name a source file or test. Reproduce with a cookie-heavy response and inspect how the proxy configures undici and turns failures into 502s. Done means the response succeeds above the default header limit and the overflow cause is actionable in the error output.
由索引模型根据 Issue 内容生成。
描述
[Bug]: theme dev proxy 502s on cookie-heavy storefront responses (undici default 16 KiB maxHeaderSize)
Description
shopify theme dev renders all pages as 502 ("Failed to render storefront") once the browser has cookies for the store. The storefront proxy dies parsing the upstream response headers: the response to a cookie'd request carries enough Set-Cookie headers to exceed undici's default 16 KiB header limit. The undici error (UND_ERR_HEADERS_OVERFLOW) is swallowed and surfaced as a bare TypeError: fetch failed → 502.
The theme, the dev theme, and the store are all fine — a cookie-less request to the same URL renders correctly.
Steps to reproduce
shopify theme pull --liveandshopify theme devon any store whose storefront sets a largeSet-Cookiecollection on cookie'd requests (this merchant: a Plus cosmetics store with cart/localization/tracking cookies).- Visit
http://127.0.0.1:9292/in a browser with an existing cookie jar for the store. - Every page render fails:
Failed to render storefront with status 502 (Bad Gateway).
URL: https://REDACTED-store.myshopify.com/?_fd=0&pb=0
TypeError: fetch failed
at Object.processResponse (node:internal/deps/undici/undici:12793:20)
at async ze (.../@shopify/cli/dist/chunk-CSNXCRPY.js:12:375)
- Open the same URL in an incognito window (empty cookie jar) — it renders.
curlto the same URL renders. Nodefetchfrom a fresh process renders. Only the CLI's cookie-forwarding proxy path fails.
Isolating the real error
The CLI wraps the undici error and drops error.cause. Attaching this shim via NODE_OPTIONS="--require /tmp/shim.cjs" and re-running theme dev reveals the cause:
const orig = globalThis.fetch;
globalThis.fetch = async (...args) => {
try { return await orig(...args); }
catch (e) {
console.error('[fetch-debug] URL:', String(args[0] && (args[0].url || args[0])).slice(0, 200));
console.error('[fetch-debug] cause code:', e.cause && e.cause.code, '| cause:', e.cause && e.cause.message);
throw e;
}
};
Output:
[fetch-debug] URL: https://REDACTED-store.myshopify.com/?_fd=0&pb=0
[fetch-debug] cause code: UND_ERR_HEADERS_OVERFLOW | cause: Headers Overflow Error
at Parser.trackHeader (node:internal/deps/undici/undici:7385:37)
at Parser.onHeaderValue (node:internal/deps/undici/undici:7376:14)
Supporting measurements
- Cookie-less
GET https://REDACTED-store.myshopify.com/?_fd=0&pb=0(with the CLI'sUser-Agent): 200, full 940 KB body, response header block ≈ 7.9 KB — under the 16 KiB cap, no failure. - Same request with the browser's cookie jar forwarded: the storefront returns a much larger
Set-Cookiecollection, pushing the response header block past 16 KiB →UND_ERR_HEADERS_OVERFLOW. - GET and POST (with
replace_templatesform bodies, up to 2 MB) both succeed without cookies, so neither method, body, nor header shape is the trigger — only response header size.
Suggested fix
- Configure the proxy's fetch/
Agentwith a largermaxHeaderSize(e.g. 64–128 KiB) instead of undici's 16 KiB default. Shopify storefronts legitimately set largeSet-Cookiecollections on cookie'd requests. - In the 502 error page, surface
error.cause.code(e.g.UND_ERR_HEADERS_OVERFLOW) instead of only the wrappedTypeError: fetch failedstack — it took aNODE_OPTIONSshim to find the actual cause.
Workaround
Use an incognito/private window for http://127.0.0.1:9292/, or clear site data for 127.0.0.1 and the store domain.
Environment
| CLI version | @shopify/[email protected] (pnpm global) |
| Node | v24.15.0 |
| OS | macOS 15 |
| Store | Shopify Plus storefront |
Possibly related: #8480 (theme dev proxy 502, cause not isolated — same proxy path, this report's cause code may explain it) and #3963.
- 主要语言
- TypeScript
- 星标
- 754
- 派生
- 294
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 138
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Shopify/cli 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 67/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
-
[Bug]: `shopify hydrogen dev` exits before listening when the npm registry is unreachable (p-cancelable onCancel-after-settle in latest-version chunk)可能已有人在做 @efegokdemir 于 5 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
no-issue-activity
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
farbenmeer/tapi#531 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
naver/egjs-flicking#971 ·
-
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
Tenant
难度 2/5 1-3 小时 新手友好度 66/100
MTES-MCT/Dossier-Facile-Frontend#2061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
backnotprop/plannotator#1784 ·
维护者通常 1 天内回复