Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug]: `theme dev` proxy 502s on cookie-heavy storefront responses (undici default 16 KiB `maxHeaderSize`)

Đang mở
#8,717 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@efegokdemir đang làm issue này rồi.

Từ ngày 2/10/2026.

  • #8746 của @efegokdemir — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
backend, cli

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

[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

  1. shopify theme pull --live and shopify theme dev on any store whose storefront sets a large Set-Cookie collection on cookie'd requests (this merchant: a Plus cosmetics store with cart/localization/tracking cookies).
  2. Visit http://127.0.0.1:9292/ in a browser with an existing cookie jar for the store.
  3. 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)
  1. Open the same URL in an incognito window (empty cookie jar) — it renders. curl to the same URL renders. Node fetch from 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's User-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-Cookie collection, pushing the response header block past 16 KiB → UND_ERR_HEADERS_OVERFLOW.
  • GET and POST (with replace_templates form 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

  1. Configure the proxy's fetch/Agent with a larger maxHeaderSize (e.g. 64–128 KiB) instead of undici's 16 KiB default. Shopify storefronts legitimately set large Set-Cookie collections on cookie'd requests.
  2. In the 502 error page, surface error.cause.code (e.g. UND_ERR_HEADERS_OVERFLOW) instead of only the wrapped TypeError: fetch failed stack — it took a NODE_OPTIONS shim 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.

Ngôn ngữ chính
TypeScript
Star
753
Fork
295
Merge trung bình
2 ngày 8 giờ
Pull request đã merge (30 ngày)
141

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Shopify/cli

Tất cả issue của Shopify/cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.