Skip to content

Don't swallow strings thrown in Server Components #810

@github-actions

Description

@github-actions

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:

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    nextjs-trackingTracking issue for a Next.js canary change relevant to vinext

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions