Bundle stats upload fails against AWS S3 storage (chunked Transfer-Encoding → 501 NotImplemented)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 82/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- aws, node.js, typescript
- Domínio
- cloud
Direção de pesquisa
Comece em packages/bundler-plugin-core/src/utils/uploadStats.ts e inspecione como o payload de estatísticas é construído e passado para fetchWithRetry. Verifique se o upload usa um body com comprimento conhecido e teste o plugin com o AWS S3 real; considera-se concluído quando o upload das estatísticas do bundle é bem-sucedido em vez de retornar o erro 501 de chunked-transfer.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 9
- Forks
- 10
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de codecov/codecov-javascript-bundler-plugins
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 52/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
-
Support vite v7Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
codecov/codecov-javascript-bundler-plugins#264 · 9 comentários · 37 reações ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
Todas as issues de codecov/codecov-javascript-bundler-plugins
Issues semelhantes
-
needs:triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia
-
ai-discovered
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
jessepollak/home#1627 ·
Mantenedores costumam responder em até 1 dia
-
agent-canvas bug llm priority:low ready-for-dev
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
OpenHands/OpenHands#17806 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
radius-project/ai-extensions#923 ·
Mantenedores costumam responder em até 1 dia