Skip to content

Conversation

@GerryWilko
Copy link
Contributor

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Description

I noticed that Nuxt 300-400 status codes from the app are being reported to Sentry unnecessarily. There appears to be a guard against doing this on the server side errors but client side errors like 404 or 401s are being reported to Sentry.

I have simply added the same guard on the client side error reporter for the Nuxt integration of Sentry.

@GerryWilko
Copy link
Contributor Author

@s1gr1d apologies for the call out but I'm not sure how to get this reviewed. You seem to be the resident Nuxt expert at Sentry looking at previous PRs?

@lforst lforst changed the title fix(nuxt): ignore 300-400 status codes on app errors in Nuxt fix(nuxt): Ignore 300-400 status codes on app errors in Nuxt Feb 25, 2025
Copy link
Contributor

@lforst lforst left a comment

Choose a reason for hiding this comment

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

This seems very reasonable to me. @s1gr1d feel free to merge if this also makes sense to you!

Comment on lines +69 to +71
if (isNuxtError(error)) {
// Do not report if status code is 3xx or 4xx
if (error.statusCode >= 300 && error.statusCode < 500) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The 2 conditions could be ANDed.

Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

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

This looks good to me. At first I thought this might not make sense as this is a client-only plugin and we would need to create an explicit server plugin (for Nuxt, not Nitro).
Nitro runs only in the server folder, but Nuxt also runs on the server when it does e.g. SSR.

However, I tested this and it seems like the errors from the Nuxt server side are passed to the client and the hook is called on the client as well. So this change is fine.

@s1gr1d s1gr1d merged commit 2140b53 into getsentry:develop Feb 26, 2025
32 checks passed
AbhiPrasad pushed a commit that referenced this pull request Feb 26, 2025
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #15473

Co-authored-by: s1gr1d <[email protected]>
@GerryWilko GerryWilko deleted the patch-1 branch March 18, 2025 13:55
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.

3 participants