Throw errors on render if onError is not defined#3518
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: eeb692c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📚 TypeDoc Generation Result✅ TypeDoc generated successfully!
The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates next-sanity/live error handling so that Live subscription and event-processing errors are no longer silently logged by default: if no onError handler is provided, the error is re-thrown during render to be handled by the nearest React error boundary. It also introduces a new SanityLiveOnError type export (with added context) and adjusts exported type names.
Changes:
- Change
<SanityLive />default error behavior to throw during render whenonErroris not provided, enabling React error boundary handling. - Add/export
SanityLiveOnErrorand update type exports (including removal ofDefinedSanity*aliases in favor ofDefined*names). - Add an MVP app example error boundary implementation and
sonnertoaster integration.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds lockfile entries for sonner used by the MVP example app. |
| packages/next-sanity/src/live/shared/types.ts | Updates onError typing + introduces SanityLiveOnError type export. |
| packages/next-sanity/src/live/conditions/react-server/index.ts | Updates re-exported type names and adds SanityLiveOnError export. |
| packages/next-sanity/src/live/conditions/next-js/index.ts | Updates re-exported type names and adds SanityLiveOnError export. |
| packages/next-sanity/src/live/conditions/default/index.ts | Updates re-exported type names and adds SanityLiveOnError export. |
| packages/next-sanity/src/live/client-components/SanityLive.tsx | Implements “throw on render when no onError” behavior and routes subscription errors through the new handler. |
| apps/mvp/package.json | Adds sonner dependency for toast-based error UI. |
| apps/mvp/app/(website)/SanityLiveErrorBoundary.tsx | New client error boundary implementation using unstable_catchError + sonner. |
| apps/mvp/app/(website)/page.tsx | Wraps <SanityLive /> with the new error boundary in the MVP example. |
| apps/mvp/app/(website)/no-resolve-perspective/page.tsx | Demonstrates passing a custom onError handler to preserve prior logging behavior. |
| apps/mvp/app/(website)/no-resolve-perspective/client-functions.ts | Adds a sample onError implementation using isCorsOriginError. |
| apps/mvp/app/(website)/layout.tsx | Adds sonner <Toaster /> to support toast notifications. |
| .changeset/violet-eels-cover.md | Changeset documenting renamed type exports on next-sanity/live. |
| .changeset/cute-stamps-return.md | Changeset documenting new throw-on-render behavior and migration examples. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
547ec82 to
2f38886
Compare
2f38886 to
eeb692c
Compare
Split from #3109