Skip to content

fix(cli): Upload chunks over HTTP/1.1 to stop HTTP/2 stream resets - #2210

Merged
BYK merged 4 commits into
getsentry:mainfrom
tustanivsky:fix/cli-chunk-upload-h2-calm
Nov 12, 2026
Merged

BYK merged 4 commits into
getsentry:mainfrom
tustanivsky:fix/cli-chunk-upload-h2-calm

Conversation

@tustanivsky

Copy link
Copy Markdown
Contributor

Summary

sentry debug-files upload from the standalone binaries fails at random with Unexpected error: TypeError: fetch failed (#2201).

The binaries use Node 26, whose fetch (undici 8) uses HTTP/2 by default. The parallel chunk uploads (concurrency: 8, up to 32 MiB each) then share one HTTP/2 connection, and Sentry's edge resets all concurrent upload streams except the last one with ENHANCE_YOUR_CALM. Retries hit the same reset, and the error reached the user without its cause.

Changes

  • Chunk uploads use an HTTP/1.1 dispatcher (allowH2: false) with one connection per request, as legacy sentry-cli does. createHttp1Dispatcher() builds it from the runtime's own global dispatcher class, so no undici dependency is added and NODE_USE_ENV_PROXY still applies.
  • getSdkConfig takes a dispatcher option, next to idempotent and timeoutMs. Each upload creates its dispatcher and destroys it afterwards.
  • A chunk upload that gets no response throws an ApiError that names the network cause, not a bare TypeError.
  • HTTP/2 with one stream per connection was rejected: on undici 8 it opens only 3 connections for 8 uploads and was about 2.5x slower than HTTP/1.1.

Testing

  • Unit tests for the dispatcher, the dispatcher option, and the chunk-upload error path.
  • Live upload of a debug file with 220 MiB of new random data to sentry.io, Windows binary built from this branch: before, 0/2 succeeded (about 75 s, then fetch failed); after, 4/4 succeeded in about 10 s with no retries.
  • 8 parallel POSTs to a local HTTP/2 server on Node 26.13.1 and Node 24.22.1 all went over HTTP/1.1.

Fixes #2201

tustanivsky and others added 4 commits November 12, 2026 16:21
The standalone binaries run Node 26, whose fetch (undici 8) uses HTTP/2
by default. Parallel chunk-upload requests then share one connection as
HTTP/2 streams, and Sentry's edge resets all but one concurrent upload
stream with ENHANCE_YOUR_CALM. Each retry hits the same reset, so large
uploads (debug files with many new chunks) failed with a bare
"TypeError: fetch failed".

Chunk uploads now use a scoped HTTP/1.1 dispatcher, one connection per
concurrent request, as the legacy sentry-cli (curl without HTTP/2) did.
The dispatcher is built from the runtime's own global dispatcher class,
so no undici dependency is added and NODE_USE_ENV_PROXY still applies;
runtimes whose fetch defaults to HTTP/1.1 are unchanged.

A chunk upload that gets no response now throws an ApiError that names
the network cause instead of the bare TypeError.

Co-Authored-By: BYK <[email protected]>
Add a `dispatcher` option to the authenticated fetch, next to
`idempotent` and `timeoutMs`, so chunk uploads no longer wrap the fetch
and cast its init. Type the dispatcher as fetch's own `dispatcher`.

Mock the dispatcher module in the chunk upload tests instead of faking
undici's global dispatcher, and trim repeated comments.

Co-Authored-By: BYK <[email protected]>
Node 24 (undici 7) also registers undici.globalDispatcher.2, so the
dispatcher is created there too; it just keeps HTTP/1.1. Note that Node
registers the dispatcher on the first fetch.

Refs getsentry#2201

Co-Authored-By: BYK <[email protected]>
…am per connection

With maxConcurrentStreams: 1, undici 8 opens only 3 HTTP/2 connections
for 8 parallel uploads and queues the rest; locally that was about 2.5x
slower than HTTP/1.1 with one connection per upload.

Refs getsentry#2201

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 12, 2026 7:17pm UTC

Request Review

@vercel

vercel Bot commented Nov 12, 2026

Copy link
Copy Markdown

@sentry-junior[bot] is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 12, 2026
@BYK
BYK enabled auto-merge (squash) November 12, 2026 21:50
@BYK
BYK merged commit d9eff4f into getsentry:main Nov 12, 2026
17 of 18 checks passed
@tustanivsky
tustanivsky deleted the fix/cli-chunk-upload-h2-calm branch November 13, 2026 06:53
BYK pushed a commit that referenced this pull request Nov 19, 2026
…esets (#2439)

`sentry snapshots upload` fails with a bare `Unexpected error:
TypeError: fetch failed` once a snapshot has three or more images over 1
MiB. Objectstore requests now go over HTTP/1.1, as chunk uploads already
do since #2210, and a failed request shows its network cause.

This is the same issue as #2201. Images over 1 MiB are PUT individually,
5 at a time, and on Node 26 they share one HTTP/2 connection, where
Sentry's edge resets most streams with `ENHANCE_YOUR_CALM`. I checked
this with `@sentry/api`'s `putObjects` and a logging fetch on 16 images
of 6–8 MB: over HTTP/2, 3 of the first 5 PUTs were reset; over HTTP/1.1
with the same concurrency, all 16 uploaded in about 6 s. The objectstore
client is unchanged up to `@sentry/api` 2.16.0, so the fix stays in the
CLI adapter.

This branch was previously deployed

1 inactive deployment
Preview — 051c017b Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug-files upload fails with "TypeError: fetch failed" (HTTP/2 stream resets)

2 participants