Bundle stats upload fails against AWS S3 storage (chunked Transfer-Encoding → 501 NotImplemented)
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 82/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 冷清
- 技術堆疊
- aws, node.js, typescript
- 領域
- cloud
研究方向
從 packages/bundler-plugin-core/src/utils/uploadStats.ts 開始,檢查 stats payload 如何建構並傳遞給 fetchWithRetry。驗證上傳使用長度已知的 body,並針對真實的 AWS S3 測試該 plugin;當 bundle stats 上傳成功,而不是回傳 chunked-transfer 501 錯誤時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Summary
uploadStats sends the stats payload as a streamed request body (ReadableStream + duplex: "half"), which undici serializes with Transfer-Encoding: chunked (no Content-Length). Amazon S3 does not support chunked PUTs and rejects the pre-signed upload with 501 NotImplemented, so bundle analysis is completely non-functional on any self-hosted Codecov instance whose storage backend is real AWS S3.
MinIO (the common self-hosted default) is lenient and accepts chunked, which is likely why this hasn't surfaced widely — but a Codecov Enterprise instance configured with services.minio.host: s3.amazonaws.com hits it every time.
Environment
@codecov/vite-plugin2.0.1 (@codecov/bundler-plugin-core2.0.1)- Node.js v24.14.1
- Self-hosted Codecov (Enterprise
25.5.1) with storage backend = AWS S3 (services.minio.host: s3.amazonaws.com)
Root cause
In packages/bundler-plugin-core/src/utils/uploadStats.ts the body is a stream:
const stream = new ReadableStream({
pull(controller) { /* ... enqueue chars ... */ },
}).pipeThrough(new TextEncoderStream());
await fetchWithRetry({
url: preSignedUrl,
requestData: {
method: "PUT",
headers: { "Content-Type": "application/json" },
duplex: "half",
body: stream, // <-- undici sends Transfer-Encoding: chunked, no Content-Length
},
});
A streamed body with no known length is sent as Transfer-Encoding: chunked. S3 returns:
<Error>
<Code>NotImplemented</Code>
<Message>A header you provided implies functionality that is not implemented</Message>
<Header>Transfer-Encoding</Header>
</Error>
With a large real payload, S3 responds 501 and closes the socket mid-upload, so undici surfaces it as a low-level TypeError: fetch failed (rethrown from fetchWithRetry) rather than the clean 501 — hence the opaque Failed to upload stats, fetch failed users see. With a tiny payload the full body flushes first and you get the clean 501.
Reproduction
- Configure a self-hosted Codecov whose storage is genuine AWS S3.
- Run any build with the plugin enabled +
CODECOV_TOKENset, pointingapiUrlat that instance. - Pre-signed URL fetch succeeds;
upload-statsfails 3× →Failed to upload stats, fetch failed.
Minimal repro of the underlying HTTP behavior (Node fetch → S3 pre-signed PUT):
// buffered string body -> Content-Length set -> 200 OK
await fetch(preSignedUrl, { method: "PUT", headers: { "Content-Type": "application/json" }, body: statsJson })
// streamed body + duplex:"half" -> Transfer-Encoding: chunked -> 501 NotImplemented
const stream = new ReadableStream({ /* enqueue chars */ }).pipeThrough(new TextEncoderStream())
await fetch(preSignedUrl, { method: "PUT", headers: { "Content-Type": "application/json" }, duplex: "half", body: stream })
Suggested fix
Send the payload as a buffered string/Uint8Array so fetch sets Content-Length, instead of a ReadableStream:
await fetchWithRetry({
url: preSignedUrl,
requestData: {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: message, // string -> Content-Length, S3-compatible
},
});
The stats JSON is already fully in memory (it's iterated char-by-char to build the stream), so buffering it adds no meaningful memory overhead and makes uploads compatible with S3 as well as MinIO/GCS.
Alternatively, keep streaming but compute and set an explicit Content-Length header, or use S3's aws-chunked content-encoding — but a plain buffered body is by far the simplest and works across all backends.
I've verified the buffered-body change fixes uploads against AWS S3 end-to-end (Successfully uploaded stats). Happy to open a PR if useful.
- 主要語言
- TypeScript
- 星號
- 9
- 分支
- 10
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codecov/codecov-javascript-bundler-plugins 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 63/100
-
難度 3/5 1-2 天 新手友好度 52/100
-
難度 4/5 3-5 天 新手友好度 35/100
-
Support vite v7未關閉
難度 3/5 1-2 天 新手友好度 58/100
codecov/codecov-javascript-bundler-plugins#264 · 9 則留言 · 37 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 45/100
查看 codecov/codecov-javascript-bundler-plugins 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
callstackincubator/rozenite#518 ·
維護者通常 1 天內回覆
-
Area/Workflow Priority/Blocker Type/Bug
難度 2/5 1-3 小時 新手友好度 76/100
wso2/product-integrator#2622 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
-
area:bash bug has repro platform:macos
難度 2/5 1-3 小時 新手友好度 78/100
anthropics/claude-code#98644 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
allure-framework/allure-js#1603 ·
維護者通常 1 天內回覆