Skip to content

feat: add SSR error handling playground example#1150

Open
travisbreaks wants to merge 1 commit intovitejs:mainfrom
travisbreaks:feat/error-handling-example
Open

feat: add SSR error handling playground example#1150
travisbreaks wants to merge 1 commit intovitejs:mainfrom
travisbreaks:feat/error-handling-example

Conversation

@travisbreaks
Copy link

Summary

Closes #795.

Adds a comprehensive SSR error handling playground demonstrating React 19 error handling patterns with vite-plugin-react's RSC/SSR support.

Patterns covered:

  • onError callback on renderToReadableStream for server-side error logging
  • digest property forwarding from server errors to client error boundaries
  • React.captureOwnerStack() for owner-chain debugging in development
  • SSR-to-CSR fallback when the shell fails to render
  • onRecoverableError for hydration mismatch detection

What's included:

  • playground/ssr-react-error-handling/ with entry-server, entry-client, ErrorBoundary, and page components for each error scenario
  • Integration tests verifying SSR output, error boundary activation, and digest visibility
  • README documenting all five patterns with code snippets

Test plan

  • pnpm dev in playground, visit each error page
  • Verify server-side onError fires with digest
  • Verify client ErrorBoundary catches and displays digest
  • Verify CSR fallback when SSR shell fails
  • Integration tests pass

Add a new playground demonstrating React 19 SSR error handling patterns:

- onError callback on renderToReadableStream for server-side error logging
- digest property for opaque error identification across server/client
- captureOwnerStack for owner-chain debugging in development
- SSR-to-CSR fallback when the server shell fails to render
- onRecoverableError on hydrateRoot for hydration mismatch logging
- ErrorBoundary component catching both SSR and client-only errors

Includes two error scenario pages (ThrowsRender, ThrowsEffect),
integration tests, and a README documenting each pattern.

Closes vitejs#795

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add error handling example

1 participant