Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/nitro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"@sentry/server-utils": "10.67.0"
},
"devDependencies": {
"nitro": "^3.0.260415-beta",
"h3": "^2.0.1-rc.22"
"nitro": "^3.0.260415-beta"
},
"scripts": {
"build": "run-p build:transpile build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/runtime/hooks/captureErrorHook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { captureException, getClient, parseUrl } from '@sentry/core';
import { flushIfServerless } from '@sentry/core/server';
import { HTTPError } from 'h3';
import { HTTPError } from 'nitro/h3';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The HTTPError class is imported from 'nitro/h3' instead of the documented path 'nitro', which may cause HTTPError.isError() checks to fail at runtime.
Severity: MEDIUM

Suggested Fix

According to the official Nitro v3 migration documentation, change the import statement for HTTPError from import { HTTPError } from 'nitro/h3' to import { HTTPError } from 'nitro'. This change should be applied in both captureErrorHook.ts and its corresponding test file.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/nitro/src/runtime/hooks/captureErrorHook.ts#L3

Potential issue: The `HTTPError` class is imported from `'nitro/h3'`, but official Nitro
documentation specifies it should be imported from the top-level `'nitro'` package. The
`captureErrorHook` uses `HTTPError.isError()` to determine if an error should be ignored
(e.g., for HTTP status codes in the 3xx/4xx range). If the `HTTPError` class from
`'nitro/h3'` is different from the one used by the Nitro runtime, this check will fail.
Consequently, client-side errors like 404s will be incorrectly reported to Sentry,
creating noise and potentially hiding real issues.

Also affects:

  • packages/nitro/test/runtime/hooks/captureErrorHook.test.ts:3~3

Did we get this right? 👍 / 👎 to inform future reviews.

import type { CapturedErrorContext } from 'nitro/types';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/runtime/hooks/captureTracingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
setHttpServerSpanRouteAttribute,
type TracingChannelPayloadWithSpan,
} from '@sentry/server-utils';
import type { TracingRequestEvent as H3TracingRequestEvent } from 'h3/tracing';
import type { TracingRequestEvent as H3TracingRequestEvent } from 'nitro/h3/tracing';
import type { RequestEvent as SrvxRequestEvent } from 'srvx/tracing';
import { setServerTimingHeaders } from './setServerTimingHeaders';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getTraceData } from '@sentry/core';
import type { TracingRequestEvent as H3TracingRequestEvent } from 'h3/tracing';
import type { TracingRequestEvent as H3TracingRequestEvent } from 'nitro/h3/tracing';

/**
* Sets Server-Timing response headers for trace propagation to the client.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as SentryCore from '@sentry/core';
import * as SentryCoreServer from '@sentry/core/server';
import { HTTPError } from 'h3';
import { HTTPError } from 'nitro/h3';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { captureErrorHook } from '../../../src/runtime/hooks/captureErrorHook';

Expand Down