Skip to content

Log noise: "The destination stream closed early." is a known Next 16.3.0 regression (vercel/next.js#96704) #377

Closed

Description

@blove

Every website e2e run logs 37-46 copies of ⨯ Error: The destination stream closed early., all with one digest. All 112 tests pass and no user-visible symptom exists. Filing so nobody re-derives this.

Cause — confirmed upstream and reproduced locally

A known, open Next.js regression: vercel/next.js#96704, reported against 16.3.1-canary.3 / react 19.2.8. Also #96465 (auto-closed for lacking a repro, not on the merits). Two fix PRs open, neither merged: #96715, #96717. No maintainer has commented on either thread.

A community bisection varying only next: 16.2.11 clean, 16.3.0 reproduces, 16.3.1-canary.9 still reproduces. 16.3.0 is where __NEXT_USE_NODE_STREAMS was switched on, routing RSC through pipeNodeReadableToNodeResponse. Verified in our own install:

  • dist/build/define-env.js:92 — hardcoded true, no config opt-out.
  • dist/server/pipe-readable.js:150-153 — res.once('close', () => readable.destroy()), destroy with no reason.
  • React therefore synthesises Error("The destination stream closed early."), name === "Error".
  • dist/server/pipe-readable.js:32-34 — isAbortError matches on name only (AbortError / ResponseAborted), so it does not silence it, and create-error-handler.js logs it.

Why a completed response never logs it

From React's source (react-server-dom-turbopack-server.node.development.js): pipe() registers destination.on("close", createCancelHandler(...)) at :6954, and abort() at :4409 is guarded by if (!(11 < request.status)). Successful renders set status = CLOSED (14) before calling destination.end() (:4326). So the later close hits the guard and is a silent no-op.

Every occurrence therefore means a Flight render was still in progress when its socket closed. There is no benign-completion path.

Local proof

A logging reverse proxy in front of next start, correlating socket closes with in-flight renders:

proxy behaviour mid-stream client disconnects errors suite
pass through (destroy upstream) 111 40 112/112
absorb after headers 67 absorbed, 42 destroyed pre-headers 13 112/112
absorb fully (drain, never destroy) 103 absorbed 0 112/112

Driving the early close to zero drives the error to zero. The aborted requests are overwhelmingly ?_rsc= prefetches of /docs/** — <Link> prefetches from the docs sidebar's 41 links, cancelled when Playwright tears a page down. /docs/[[...slug]] is the only request-time Flight render in a production build; everything else is prerendered.

Notably favicon.ico is a prerendered route handler, not a Flight render — the favicon test is implicated only by when it ends (immediately after waitForDocsReady, at the peak of the prefetch burst), not by what it fetches.

What we should do

Nothing, for now. There is no supported suppression: onRequestError is the only hook and we do not export one; the console line comes from Next's own logging with no documented filter. Pinning to 16.2.x would trade real fixes for log tidiness.

Watch vercel/next.js#96704 and drop this issue when it lands.

Related

#376 halves docs render time by removing a duplicate MDX+shiki compile. That narrows the window but does not fix this (34 lines after vs 37-46 before — noise).

Dead ends, so nobody repeats them

Each produced zero: complete HTML loads; complete RSC loads; curl aborts on both; Node socket-destroy on first byte across five route/mode combinations; real Chromium closing the context at 0/50/150/400/1200ms; cold vs warm server; hydration-then-teardown; prefetches allowed to settle; the query-stringed favicon URL repeated; request.get before page.goto. Patching Next's compiled runtime to log the request URL breaks it — destination is not bound at all three occurrences of the string; 30 tests fail. Use an external proxy instead.

Activity

  1. blove commented on Aug 14, 2026

    @blove
    ContributorAuthor

    Validated both upstream PRs against our own suite rather than waiting. Posted the numbers to vercel/next.js#96704.

    Both PRs eliminate the error completely, and both preserve render cancellation.

    Arm closed early per suite run Tests
    16.3.0 unmodified 42, 30, 30 112/112
    16.3.0 unmodified, quiet re-run 28 112/112
    #96715 0, 0, 0 112/112
    #96717 0, 0, 0 112/112

    The quiet re-run matters: the PR arms happened to run on a much less loaded machine, and lower load narrows the window a disconnect can land in. Re-measuring the unmodified baseline under the same quiet conditions still gave 28, so the zeros are the patches rather than the machine.

    A second app checked what the error count cannot: a fix that simply stopped cancelling renders would also score zero, while quietly burning server time finishing responses nobody reads. Both PRs keep the cancellation and drop only the misreport, with a positive control confirming the check can fire.

    Two things that change the advice in this issue:

    1. 16.3.1 does not fix it. Verified in the shipped dist, not the version string — isAbortError is byte-identical to 16.3.0's name-only check and neither PR's marker is present. Note next: "^16.3.0" means a bare pnpm install moves us to 16.3.1 silently; that is how this was found.
    2. The two PRs are complementary, not competing — a real trial merge applies cleanly. Nothing to choose between; either landing fixes us.

    Still nothing for us to do here beyond watching #96704. No local patch, no version pin.

    Related: #376 halves docs render time, which narrows the window but does not fix this (34 lines after vs 37-46 before, i.e. noise).

  2. blove commented on Aug 31, 2026

    @blove
    ContributorAuthor

    Rechecked 2026-08-30 from current main (77e56cb0) against the shipped packages and the full production-mode browser suite.

    Upstream status — fix merged, but not in a stable release yet

    Confirmed: vercel/next.js#96704 is now closed as completed. #96715 merged on 2026-08-26 as 0c7f81e6. #96717 was then closed as superseded by that shared-helper fix.

    The merged test is the contract we need: abort a streaming RSC response after its fallback arrives, assert that the client abort is not reported, then cause a genuine server render exception and assert that onRequestError still receives server-side-error. This is not string filtering and does not hide real rendering failures.

    Confirmed release state: npm's stable latest is still next@16.3.3, published 2026-08-25 15:32 UTC — about 29 hours before the fix merged. There is no stable Next release containing the fix today. The first package I verified with the merged code is 16.4.0-canary.9, published 2026-08-27 00:53 UTC.

    Shipped-artifact check, not version-name inference:

    • Our lockfile resolves next@16.3.3 and @next/mdx@16.3.3 from declared ranges ^16.3.3.
    • 16.3.3's dist/server/app-render/stream-ops.node.js pipes to the PassThrough without the new close handler; its pipe-readable.js still calls bare readable.destroy() on response close.
    • 16.4.0-canary.9's published tarball contains the merged pre-pipe pt.once('close', ...) handler and calls pipeable.abort(new ResponseAborted()) when the destination closes before writableEnded.

    Disposition/judgment: do not move this production app to a 16.4 prerelease solely for log tidiness. That would take unrelated canary changes and bypass the repository's stable semver/Dependabot path. No dependency or workaround change is warranted yet.

    Current reproduction and impact

    Built the current website with Node 24.19.0 / pnpm 10.12.1 / Next 16.3.3, launched next start, and ran the complete local production smoke against it:

    Running 342 tests using 5 workers
    338 passed, 4 expected dev-mode skips (5.2m)
    231 x "The destination stream closed early."
    231 x digest '1393988370'
    0 other server error markers
    

    The count is timing- and workload-dependent and is higher than the original report because the suite has grown from 112 to 342 cases. The impact remains observability/log noise from client-cancelled in-flight RSC requests: the full Chromium/WebKit suite is green and no user-visible symptom was observed.

    There is still no local workaround to remove: no instrumentation/onRequestError export, patched dependency, log-string suppression, blanket console filter, or error-name filter exists in the website.

    Exact unblock and recheck plan

    Leave this open until npm publishes a stable next release (and matching @next/mdx) whose shipped stream-ops.node.js contains the 0c7f81e6 abort-before-pipe fix. Do not infer inclusion from the version number or from #96704 being closed; inspect the published artifact.

    On the first stable release after 16.3.3:

    1. Update next and @next/mdx together and inspect the installed dist for the typed pre-pipe abort handler.
    2. Add a project regression twin modeled on upstream: client-abort a live RSC stream and require no false report, then trigger a genuine server render failure and require that it remains visible through the server log/onRequestError path.
    3. Run website unit tests, SSR/hydration coverage, production build, lint/type checks, packaging checks, and the full Chromium/WebKit production smoke.
    4. Only close this issue if the log count is zero for the abort case, the positive-control render failure is still reported, and all gates pass.

    The weekly dependency update should surface the next stable automatically; the recheck trigger is a stable npm version newer than 16.3.3, followed by artifact verification.

  3. blove commented on Aug 31, 2026

    @blove
    ContributorAuthor

    Rechecked 2026-08-31 after npm moved both next and @next/mdx stable latest to 16.3.4.

    The unblock condition is not met. I inspected the published next-16.3.4.tgz (sha512-/Ztf6CeRH+ejEXUrYtqI4gkS66eFIHuSwqi60RgcpWKodxFZx2/dqVCMKBwILfAHXQ+F1b1vAudgj3mnxqtoIA==) and the authoritative v16.3.4 tagged source, tag commit 299180d3315c7ebd7b199d2b1a265b5986c5fc7d. Both still call pipeable.pipe(pt) immediately and omit the pre-pipe close listener, writableEnded check, and pipeable.abort(new ResponseAborted()) added by 0c7f81e6. GitHub comparison reports the fix commit and the 16.3.4 release tag as diverged, consistent with the artifact evidence.

    As a control, the published 16.4.0-canary.12 artifact does contain that exact ResponseAborted pre-pipe handler. Therefore the fix remains canary-only despite the new stable patch release.

    No dependency/code change or PR was created: upgrading from 16.3.3 to 16.3.4 would not resolve the regression, and moving production to a canary or filtering the log would violate the safety constraints. This issue remains open. Recheck the next stable artifact; proceed only when it contains the upstream handler and a matching stable @next/mdx is available.

  4. blove commented on Sep 1, 2026

    @blove
    ContributorAuthor

    Status check (2026-09-01): upstream fix merged, but not in any 16.3.x

    The premise here has not expired, so this stays open — but the closing condition is now exact.

    vercel/next.js#96715 — "Don't report a client-aborted RSC stream as a render error" — merged 2026-08-26 into canary (0c7f81e6), closing vercel/next.js#96704.

    It has not been backported to the 16.3 line. Verified by inspecting the shipped dist of each version rather than trusting version numbers, with a canary as a positive control so the check demonstrably distinguishes present from absent:

    version fix present?
    16.3.3 (what we had installed) absent
    16.3.4 (latest, released 2026-08-31) absent
    16.4.0-canary.13 present

    Grep marker: pipeable.abort(new ResponseAborted()).

    So bumping within 16.3.x will not help. Closing condition: upgrade to 16.4.0 stable (or a 16.3.x that backports it), then confirm the occurrence count drops to 0.

    Correction: we were watching the wrong file

    This issue describes the cause as pipe-readable.js doing a bare readable.destroy() with no reason. That is an accurate description of the mechanism, but it is the wrong place to watch for a fix — that line is unchanged even in canary (canary's only diff to pipe-readable.ts is an unrelated compression/drain-listener leak fix). Anyone diffing that file across releases would conclude "still broken" indefinitely.

    The actual repair is 12 lines in server/app-render/stream-ops.node.ts, inside renderToNodeFlightStream:

    pt.once('close', () => {
      if (!pt.writableEnded) {
        pipeable.abort(new ResponseAborted())
      }
    })
    pipeable.pipe(pt)

    The listener is registered before piping, so it runs before React's. The abort then carries a reason instead of React's generic Error, and the existing name-only isAbortError matches it correctly. That also explains why isAbortError itself was never changed — it did not need to be.

    One measurement trap

    A recycled worktree had Next 16.3.0 installed while the lockfile resolves 16.3.3. Run pnpm install --frozen-lockfile before inspecting, or you will read the wrong dist and draw a confident wrong conclusion.

    No behavior change on our side; still 0 user-visible symptoms and a green suite. Note this check was done by dist inspection, not by a fresh e2e run, so it does not restate a current occurrence count.

  5. blove commented on Nov 13, 2026

    @blove
    ContributorAuthor

    Resolved by #617 (Next.js 16.4.5), deployed as e17ab4f. Production /version.json reports that commit, and both the production deployment and freshness checks passed. The regression fixture reproduced two stream-closed errors on 16.3.3 and zero on 16.4.5 while preserving cancellation and genuine-error reporting. Hosted preview coverage passed 446 tests; a fresh live-production smoke run passed all 38 Chromium/WebKit cases. The production runtime-log query covering the smoke run returned zero matching destination-stream-closed errors (and no runtime entries in that window). This is bounded verification of the regression, not a claim that all future server errors are impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions