GeezerVison is showing github.com — feat(nuxt): Capture errors caught by <NuxtErrorBoundary> during SSR by pranav514 · Pull Request #26815 · getsentry/sentry-javascript
feat(nuxt): Capture errors caught by <NuxtErrorBoundary> during SSR
#26815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
if (import.meta.server) {
throw new Error('SSR Error inside NuxtErrorBoundary');
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:
exportdefaultdefineNuxtPlugin(nuxtApp=>{constcaught: Parameters<typeofreportNuxtError>[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.
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.tscaptureException(error,{captureContext: {contexts: {nuxt: metadata}},mechanism: {handled: false,type: `auto.function.nuxt.${instance ? 'vue' : 'app'}-error`},});// in sentry.client.tssetTimeout(()=>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
});
});
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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.