Skip to content

Throw errors on render if onError is not defined#3518

Merged
stipsan merged 1 commit into
mainfrom
throw-errors-during-render-if-no-onError
May 11, 2026
Merged

Throw errors on render if onError is not defined#3518
stipsan merged 1 commit into
mainfrom
throw-errors-during-render-if-no-onError

Conversation

@stipsan
Copy link
Copy Markdown
Member

@stipsan stipsan commented May 11, 2026

Split from #3109

Copilot AI review requested due to automatic review settings May 11, 2026 18:26
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
next-sanity Ready Ready Preview, Comment May 11, 2026 6:46pm
next-sanity-static Ready Ready Preview, Comment May 11, 2026 6:46pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: eeb692c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
next-sanity Major

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

📚 TypeDoc Generation Result

TypeDoc generated successfully!

  • File size: 2.5M
  • Total exports: 267
  • Artifact: typedoc-8ccbd25018b3184186a643a9f12fb6f725669823
  • HTML docs preview: Download artifact

The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 11, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​sonner@​2.0.71001008383100

View full report

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when onError is not provided, enabling React error boundary handling.
  • Add/export SanityLiveOnError and update type exports (including removal of DefinedSanity* aliases in favor of Defined* names).
  • Add an MVP app example error boundary implementation and sonner toaster 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.

Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx Outdated
Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx Outdated
Comment thread apps/mvp/app/(website)/SanityLiveErrorBoundary.tsx
Comment thread .changeset/cute-stamps-return.md Outdated
Comment thread packages/next-sanity/src/live/shared/types.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/next-sanity/src/live/shared/types.ts
Comment thread apps/mvp/app/(website)/SanityLiveErrorBoundary.tsx
Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx
Comment thread packages/next-sanity/src/live/client-components/SanityLive.tsx
@stipsan stipsan merged commit ee00392 into main May 11, 2026
11 checks passed
@stipsan stipsan deleted the throw-errors-during-render-if-no-onError branch May 11, 2026 18:51
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.

2 participants