GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(nuxt): Capture errors caught by <NuxtErrorBoundary> during SSR by pranav514 · Pull Request #26815 · getsentry/sentry-javascript

Conversation

@pranav514

@pranav514 pranav514 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What

Captures errors caught by <NuxtErrorBoundary> during SSR in Nuxt 4.7+ and reports them to Sentry.

Why

In Nuxt 4.7+, <NuxtErrorBoundary> supports SSR and catches component errors to render its #error slot with a 200 HTTP response. These errors never reached Sentry because Nitro's error hook only fires for unhandled server crashes and the client plugin does not receive vue:error during hydration. We buffer server-side vue:error events and report them on app:rendered via reportNuxtError, while ignoring intentional 3xx/4xx control-flow errors and fatal page crashes already reported by Nitro.

Closes: #26795

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the external PR from an external contributor label Nov 24, 2026
@javascript-sdk-gitflow
javascript-sdk-gitflow Bot requested review from chargome, nicohrubec and s1gr1d November 24, 2026 12:53
@pranav514
pranav514 force-pushed the feat/nuxt-ssr-error-boundary branch from 66b8cea to ecc2714 Compare November 24, 2026 12:56
@pranav514

pranav514 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@JPeer264 @chargome @nicohrubec I've implemented a fix for this by adding a server-only plugin (error-boundary.server.ts) that listens to vue:error during SSR and flushes caught errors on app:rendered using reportNuxtError.

It skips reporting if nuxtApp.payload.error is present (so fatal page errors continue to be handled by Nitro without duplication) and filters out 3xx/4xx control-flow errors. Unit test coverage has been added. Please do review it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Nov 24, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/src/runtime/plugins/error-boundary.server.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/nuxt/src/runtime/plugins/error-boundary.server.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nicohrubec

nicohrubec commented Nov 24, 2026

Copy link
Copy Markdown
Member

@pranav514 can you please stop pinging random people from the team. we see that you opened a PR and we'll get to it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pranav514

pranav514 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@pranav514 can you please stop pinging random people from the team. we see that you opened a PR and we'll get to it.

Sure I'll take care

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

s1gr1d
s1gr1d reviewed Nov 24, 2026
View reviewed changes
Comment thread packages/nuxt/src/runtime/plugins/error-boundary.server.ts Outdated
Comment on lines +14 to +21
function isIgnoredNuxtError(error: unknown): boolean {
if (!isNuxtError(error)) {
return false;
}
// oxlint-disable-next-line typescript/no-deprecated
const statusCode = error?.status || error?.statusCode;
return !!statusCode && statusCode >= 300 && statusCode < 500;
}

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This function already exists in sentry.client.ts and can be reused. We can put this function into an utils file so it's shared and then re-use it from there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/src/runtime/plugins/error-boundary.server.ts
return !!statusCode && statusCode >= 300 && statusCode < 500;
}

export default defineNuxtPlugin(nuxtApp => {

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This plugin is re-writing a lot of code that already exists. By reusing the things we already have, this can be condensed to just this:

export default defineNuxtPlugin(nuxtApp => {
  const caught: Parameters<typeof reportNuxtError>[0][] = [];
  nuxtApp.hook('vue:error', (error, instance, info) => {
    if (!isIgnoredNuxtError(error)) caught.push({ error, instance, info });
  });
  // The Nitro `error` hook reports errors that end on the error page.
  nuxtApp.hook('app:rendered', () => {
    if (!nuxtApp.payload.error) caught.forEach(reportNuxtError);
  });
});

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/src/module.ts Outdated
addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });
}

addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/error-boundary.server'), mode: 'server' });

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Could we add this plugin only when nuxt.options.experimental.ssrErrorBoundary is on?

Otherwise, the hooks just run without doing anything.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/test/runtime/plugins/error-boundary.server.test.ts Outdated

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd replace the unit tests with one E2E case in nuxt-5: a component that throws during SSR inside <NuxtErrorBoundary>, with a check that the page returns 200 and the error reaches Sentry. These mocks can't show that Nuxt actually calls vue:error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pranav514

pranav514 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@s1gr1d Addressed all feedback:

Extracted isIgnoredNuxtError to shared runtime utils and reused it in both sentry.client.ts and error-boundary.server.ts.
Condensed error-boundary.server.ts to reuse reportNuxtError.
Guarded plugin registration so it only registers when nuxt.options.experimental.ssrErrorBoundary is enabled.
Removed the mocked unit tests and added an E2E test in nuxt-5 testing an SSR component error inside with an HTTP 200 response.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Nov 24, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit baa820c. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread dev-packages/e2e-tests/test-applications/nuxt-5/tests/errors.server.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

s1gr1d
s1gr1d reviewed Nov 24, 2026
View reviewed changes
Comment thread dev-packages/e2e-tests/test-applications/nuxt-5/tests/errors.server.test.ts Outdated

const error = await errorPromise;

expect(error.transaction).toEqual('/ssr-error-boundary');

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
expect(error.transaction).toEqual('/ssr-error-boundary');
expect(error.transaction).toEqual('GET /ssr-error-boundary');

could be that this is with GET as this is the server-side.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/src/module.ts Outdated
}

// oxlint-disable-next-line typescript/no-unsafe-member-access
if (nuxt.options.experimental && (nuxt.options.experimental as Record<string, unknown>).ssrErrorBoundary) {

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
if (nuxt.options.experimental && (nuxt.options.experimental as Record<string, unknown>).ssrErrorBoundary) {
if ((nuxt.options.experimental as { ssrErrorBoundary?: boolean }).ssrErrorBoundary) {

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts Outdated
Comment on lines +6 to +8
experimental: {
ssrErrorBoundary: true,
},

@s1gr1d s1gr1d Nov 24, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is on by default, so we can remove this flag.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pranav514

pranav514 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@s1gr1d Thanks for the review! Applied all suggested updates:

Switched to the inline type check (nuxt.options.experimental as { ssrErrorBoundary?: boolean }).ssrErrorBoundary in module.ts.
Removed the redundant experimental.ssrErrorBoundary flag from the nuxt-5 test app config.
Updated the expected transaction name to GET /ssr-error-boundary.
Updated the test assertion to await expect(page.locator('#error-fallback')).toBeVisible()

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pranav514
pranav514 requested a review from s1gr1d November 25, 2026 04:50
@pranav514
pranav514 force-pushed the feat/nuxt-ssr-error-boundary branch from a6b5818 to e3227e4 Compare November 25, 2026 06:25
pranav514 added 4 commits November 25, 2026 12:47
@pranav514
feat(nuxt): Capture errors caught by <NuxtErrorBoundary> during SSR
809c932
Nuxt 4.7 added SSR support to <NuxtErrorBoundary>, rendering its #error slot
and returning HTTP 200 when a component errors during SSR. These errors were
never forwarded to Sentry because Nitro's error hook only catches uncaught errors,
and the client plugin does not receive vue:error during hydration.
This registers a server-side Nuxt app plugin that listens to vue:error on the
server and captures caught errors during app:rendered, unless the page errored
fatally (nuxtApp.payload.error).
@pranav514
fix(nuxt): Synchronously capture and flush SSR error boundary errors
3411c42
Avoid deferring via setTimeout so events are captured before Cloudflare
or serverless request wrappers dispose the client. Calls flushIfServerless
on app:rendered to ensure pending envelopes are dispatched.
@pranav514
refactor(nuxt): Address maintainer review for SSR error boundary
5d7122a
- Share isIgnoredNuxtError in runtime utils for both client and server plugins
- Condense error-boundary.server.ts to reuse reportNuxtError
- Register plugin only when experimental.ssrErrorBoundary is enabled
- Replace unit tests with an E2E test in nuxt-5 test application
@pranav514
refactor(nuxt): Apply review suggestions for SSR error boundary E2E test
034ba29
- Use inline type for experimental.ssrErrorBoundary check
- Remove redundant experimental flag from Nuxt 5 test app config
- Expect HTTP method in server error transaction name
- Assert error fallback visibility instead of matching sanitized error text
JPeer264
JPeer264 reviewed Nov 25, 2026
View reviewed changes

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm waiting for the approval after the rebase, but after Sigrid's review it looks good

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread dev-packages/e2e-tests/test-applications/nuxt-5/app/components/SSRErrorComponent.vue
@@ -0,0 +1,9 @@
<script setup>

@JPeer264 JPeer264 Nov 25, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just a note. The original issue was reported for Cloudflare, after the merge of #26756 this PR has a merge conflict, but after a rebase it would run also on Cloudflare, so we have this case covered too. No action item other than the rebase.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pranav514
pranav514 force-pushed the feat/nuxt-ssr-error-boundary branch from e3227e4 to 034ba29 Compare November 25, 2026 07:29
@pranav514

pranav514 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@JPeer264 Rebased onto latest develop and resolved the conflict in packages/nuxt/src/module.ts. The branch now includes #26756 so the E2E test will also run against Cloudflare in CI. Ready for review!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JPeer264
JPeer264 approved these changes Nov 25, 2026
View reviewed changes

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM from my side. Waiting for @s1gr1d's approval before we merge

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
s1gr1d
s1gr1d approved these changes Nov 25, 2026
View reviewed changes

@s1gr1d s1gr1d left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

one small comment regarding the timings. And the optional nuxt-5 test does not run for external PRs in our CI, did you run that locally?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/nuxt/src/runtime/plugins/error-boundary.server.ts
});
// The Nitro `error` hook reports errors that end on the error page.
nuxtApp.hook('app:rendered', () => {
if (!nuxtApp.payload.error) caught.forEach(reportNuxtError);

@s1gr1d s1gr1d Nov 25, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

reportNuxtError wraps captureException in setTimeout. That delay is for client breadcrumbs, but now the server gets it too. On Cloudflare, the request wrapper flushes when the response ends, so the capture can come too late.

Could we remove the setTimeout from reportNuxtError and put it around the two calls in sentry.client.ts (in app:error, vue:error)? Then the server captures right away (captures in the next event loop, so that all breadcrumbs are recorded in time).

Kinda like this:

// utils.ts
captureException(error, {
  captureContext: { contexts: { nuxt: metadata } },
  mechanism: { handled: false, type: `auto.function.nuxt.${instance ? 'vue' : 'app'}-error` },
});

// in sentry.client.ts
setTimeout(() => reportNuxtError({ error }));
setTimeout(() => reportNuxtError({ error, instance, info }));

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JPeer264 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@pranav514
refactor(nuxt): Capture errors synchronously in reportNuxtError and d…
ca0c7fb
…efer in client plugin

Remove setTimeout from reportNuxtError so errors are captured immediately on the server before Cloudflare or serverless request wrappers flush and finish. Wrap calls in setTimeout within sentry.client.ts to preserve breadcrumb timing on the client.
@pranav514

pranav514 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@s1gr1d Makes complete sense! I've removed setTimeout from reportNuxtError so server-side errors (especially on Cloudflare) are captured synchronously before the response ends. The setTimeout delay is now placed directly in sentry.client.ts around app:error and vue:error to preserve client breadcrumbs.

And yes, I built the package tarballs and ran the nuxt-5 E2E tests (tests/errors.server.test.ts) locally with Playwright, all 7 server test cases passed including the new SSR error boundary test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JPeer264
JPeer264 reviewed Nov 25, 2026
View reviewed changes
Comment thread dev-packages/e2e-tests/test-applications/nuxt-5/tests/errors.server.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pranav514
test(nuxt): Guard transaction assertion for Bun in SSR error boundary…
7f5b873
… test
@pranav514

pranav514 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@JPeer264 Added the RUNTIME !== 'bun' guard and imported RUNTIME from ./runtime as suggested!

JPeer264 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JPeer264
JPeer264 merged commit a1fd756 into getsentry:develop Nov 25, 2026
325 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@javascript-sdk-gitflow javascript-sdk-gitflow Bot mentioned this pull request Nov 25, 2026
chore: Add external contributor to CHANGELOG.md #26857
Merged
JPeer264 added a commit that referenced this pull request Nov 25, 2026
@javascript-sdk-gitflow @JPeer264
chore: Add external contributor to CHANGELOG.md (#26857)
ca28546
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #26815

Co-authored-by: JPeer264 <[email protected]>
@s1gr1d s1gr1d mentioned this pull request Nov 25, 2026
ci(e2e): Only give secrets to E2E test apps that need them #26869
Merged
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Nov 25, 2026
publish: getsentry/[email protected] getsentry/publish#10573
Closed
51 tasks done
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
Nuxt: report errors caught by <NuxtErrorBoundary> during SSR #26795
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JPeer264 JPeer264 JPeer264 approved these changes
@cursor cursor[bot] cursor[bot] left review comments
@s1gr1d s1gr1d s1gr1d approved these changes
@chargome chargome Awaiting requested review from chargome
@nicohrubec nicohrubec Awaiting requested review from nicohrubec

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

external PR from an external contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Nuxt: report errors caught by <NuxtErrorBoundary> during SSR

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@pranav514 @nicohrubec @JPeer264 @s1gr1d
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.