Next.js Change
When a string (or other non-Error value) is thrown in a Server Component, Next.js previously had a code path in createReactServerErrorHandler that returned early with a hash digest, effectively swallowing the thrown value before it could be wrapped into a proper Error and logged.
The fix moves the string-handling branch into the else clause alongside the normal error digest assignment, so thrown strings are first wrapped into an Error object (by React) and then assigned a digest. This ensures:
- Thrown strings are properly logged to the server console
- The error boundary receives the original string message
- Digest generation is consistent for string vs Error throws
Upstream commit: vercel/next.js@b9ca95c
Upstream PR: vercel/next.js#92592
Relevance to vinext
vinext reimplements the RSC rendering pipeline including error handling in the App Router server entries (entries/app-rsc-entry.ts, server/ modules). If vinext has an equivalent onError handler for renderToReadableStream or the RSC stream that handles thrown values, it needs to ensure:
- Strings thrown in Server Components are not silently consumed
- They are wrapped into Error objects and logged correctly
- Digest assignment works consistently for both string and Error thrown values
Action
- Check whether vinext's RSC error handler (
entries/app-rsc-entry.ts or related server code) has an early-return path for typeof thrownValue === 'string' that could swallow the value
- If so, align with the Next.js fix: move string digest handling into the normal error processing flow
- Add a test case that throws a string in a Server Component and verifies the error boundary renders with the correct message
Next.js Change
When a string (or other non-Error value) is thrown in a Server Component, Next.js previously had a code path in
createReactServerErrorHandlerthat returned early with a hash digest, effectively swallowing the thrown value before it could be wrapped into a proper Error and logged.The fix moves the string-handling branch into the
elseclause alongside the normal error digest assignment, so thrown strings are first wrapped into an Error object (by React) and then assigned a digest. This ensures:Upstream commit: vercel/next.js@b9ca95c
Upstream PR: vercel/next.js#92592
Relevance to vinext
vinext reimplements the RSC rendering pipeline including error handling in the App Router server entries (
entries/app-rsc-entry.ts,server/modules). If vinext has an equivalentonErrorhandler forrenderToReadableStreamor the RSC stream that handles thrown values, it needs to ensure:Action
entries/app-rsc-entry.tsor related server code) has an early-return path fortypeof thrownValue === 'string'that could swallow the value