next.js icon indicating copy to clipboard operation
next.js copied to clipboard

RSC client cancellation is reported as a destination-write error in 16.4.6 and 16.5.0-canary.49

Open zmahomedy opened this issue 3 weeks ago • 1 comments

Link to the code that reproduces this issue

https://github.com/zmahomedy/next-rsc-abort-write-error-repro

To Reproduce

  1. Clone the public repository above.
  2. Run npm ci, then npm run dev.
  3. In a second terminal run npm run reproduce.
  4. Observe REPRO_REQUEST_ERROR in the server output after each cancelled RSC response.
  5. To verify canary: stop the server, run npm install --no-save --package-lock=false [email protected], restart npm run dev, then run npm run reproduce again.

The reproduction is a small App Router application with a Suspense child that waits five seconds. A Node script verifies the RSC content type, reads the first nonempty chunk, and aborts the request. There are no databases, authentication, private packages, environment variables or application dependencies beyond Next/React. No dependency patch is included.

Current vs. Expected behavior

Current: each of five client-aborted RSC requests reports a generic server-render error:

Error: The destination stream errored while writing data.
REPRO_REQUEST_ERROR {"name":"Error","message":"The destination stream errored while writing data.","path":"/?attempt=1&_rsc=","renderSource":"react-server-components-payload"}

Verified locally with a clean install: 5/5 on stable 16.4.6 and 5/5 on canary 16.5.0-canary.49, with React/React DOM 19.2.8 in both cases.

Expected: ordinary client cancellation should preserve its typed abort reason and should not be sent to onRequestError as a generic rendering failure. Genuine application errors must remain reportable.

Provide environment information

OS: macOS, darwin arm64
Node: 24.18.0
next: 16.4.6 and 16.5.0-canary.49 (both tested)
react: 19.2.8
react-dom: 19.2.8
Router: App Router
Bundler: Turbopack
Mode: next dev

Which area(s) are affected? (Select all that apply)

Error Handling, Instrumentation, Loading UI and Streaming, Linking and Navigating, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Follow-up to locked issue #96704 and merged #96715. Our first report #101719 was closed because its reproduction link was insufficient; this replacement supplies a dedicated public repository that has been run against stable and latest canary.

An application-level diagnostic observed a ResponseAborted destination error before React replaced it with the generic write error. The suspected remaining case is error preceding close in renderToNodeFlightStream: React's createCancelHandler creates a generic Error before Next's existing close handler can preserve the original reason. A separate local experiment registering pt.once("error", error => pipeable.abort(error)) before piping preserved typed cancellations and genuine errors. The public reproduction deliberately contains no workaround.

Modest system load and one sequential client were sufficient; high RAM/swap pressure is not required. This report does not claim production-mode impact; that mode has not been verified in the standalone reproduction.

zmahomedy avatar Nov 13 '26 05:11 zmahomedy

Could I investigate the RSC cancellation reporting here? I’d compare an intentional client disconnect with a genuine destination write failure and check whether the former can be handled without suppressing diagnostics for the latter.

seragAhmed avatar Nov 13 '26 07:11 seragAhmed