[GH-ISSUE #810] Don't swallow strings thrown in Server Components #179

Closed
opened 2026-05-06 12:37:55 +02:00 by BreizhHardware · 0 comments

Originally created by @github-actions[bot] on GitHub (Apr 10, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/810

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@b9ca95c62d
Upstream PR: https://github.com/vercel/next.js/pull/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:

  1. Strings thrown in Server Components are not silently consumed
  2. They are wrapped into Error objects and logged correctly
  3. 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
Originally created by @github-actions[bot] on GitHub (Apr 10, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/810 ## 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@b9ca95c62dd882eb3c0e5fc0be9b20bf0b198fb1 **Upstream PR:** https://github.com/vercel/next.js/pull/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: 1. Strings thrown in Server Components are not silently consumed 2. They are wrapped into Error objects and logged correctly 3. 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
BreizhHardware 2026-05-06 12:37:55 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#179
No description provided.