Skip to content

Nitro: Errors are reported twice #24939

Description

@MickL

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nitro

SDK Version

11.1.0

Framework Version

11.1.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

Handler /routes/sentry.ts from the docs:

import { defineHandler } from 'nitro/h3';

export default defineHandler(() => {
  throw new Error('Sentry error tracing is working!');
});

Expected Result

  • Should report one error to Sentry
  • Specific errors like 401 should not be reported to Sentry

Actual Result

  • Errors show up twice in Sentry, once as Error and once as HttpError
  • Specific errors like 401 are reported to Sentry (once) as HttpError

Additional Context

Found that @sentry/nitro reports errors from two places: The error hook (which filters 4xx) and the h3 tracing channel (which doesn't), causing duplicate reports and letting the 401 slip through unfiltered.

Priority

Critical ?

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Activity

  1. linear-code commented on Oct 1, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 1, 2026
  3. changed the title [-]Errors are reported twice[/-] [+]Nitro: Errors are reported twice[/+] on Oct 1, 2026
  4. MickL commented on Oct 1, 2026

    @MickL
    Author

    Workaround until fixed, in instrument.mjs:

    Sentry.init({
      dsn: process.env.NITRO_SENTRY_DSN,
      tracesSampleRate: 1,
      beforeSend: (event) => {
        // TODO: Remove, workaround until this is fixed: https://github.com/getsentry/sentry-javascript/issues/24939  
        if (event.exception?.values?.some(({ mechanism }) => mechanism?.type === 'auto.http.nitro.onTraceError')) {
          return null;
        }
    
        return event;
      },
    });

    This drops everything from the tracing channel (onTraceError) and keeps everything from Nitro's error hook (captureErrorHook), which is the path that skips 3xx/4xx.

  5. self-assigned this
    on Oct 1, 2026
  6. nicohrubec commented on Oct 2, 2026

    @nicohrubec
    Member

    Hey, thanks for raising! I just merged a fix so this should be working correctly in the next release.

  7. added a commit that references this issue on Oct 2, 2026
    f555a14
  8. added a commit that references this issue on Oct 2, 2026
    e8dfc58
  9. github-actions commented on Oct 2, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #24952, which was included in the 11.3.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions