From eb6a5e33bffc426f839ef658d9d44ef96787025f Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Mon, 14 Sep 2026 10:21:52 +0200 Subject: [PATCH] fix(nitro): Import from nitro/h3 instead of h3 directly --- packages/nitro/package.json | 3 +-- packages/nitro/rollup.npm.config.mjs | 2 +- packages/nitro/src/runtime/hooks/captureErrorHook.ts | 2 +- packages/nitro/src/runtime/hooks/captureTracingEvents.ts | 7 ++++--- packages/nitro/src/runtime/hooks/setServerTimingHeaders.ts | 4 ++-- packages/nitro/test/runtime/hooks/captureErrorHook.test.ts | 2 +- yarn.lock | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/nitro/package.json b/packages/nitro/package.json index c81f247e032c..3bdd6f57243c 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -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", diff --git a/packages/nitro/rollup.npm.config.mjs b/packages/nitro/rollup.npm.config.mjs index 140655a7eca8..08f1f53421dd 100644 --- a/packages/nitro/rollup.npm.config.mjs +++ b/packages/nitro/rollup.npm.config.mjs @@ -5,7 +5,7 @@ export default [ makeBaseNPMConfig({ entrypoints: ['src/index.ts', 'src/runtime/plugins/server.ts'], packageSpecificConfig: { - external: [/^nitro/, /^h3/, /^srvx/, /^@sentry\/opentelemetry/, '@sentry/bundler-plugin-core'], + external: [/^nitro/, /^srvx/, /^@sentry\/opentelemetry/, '@sentry/bundler-plugin-core'], }, }), { emitCjs: false }, diff --git a/packages/nitro/src/runtime/hooks/captureErrorHook.ts b/packages/nitro/src/runtime/hooks/captureErrorHook.ts index 2f7a602f3af1..d07bad842ea0 100644 --- a/packages/nitro/src/runtime/hooks/captureErrorHook.ts +++ b/packages/nitro/src/runtime/hooks/captureErrorHook.ts @@ -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'; import type { CapturedErrorContext } from 'nitro/types'; /** diff --git a/packages/nitro/src/runtime/hooks/captureTracingEvents.ts b/packages/nitro/src/runtime/hooks/captureTracingEvents.ts index b34a5bf7225d..bcfad9b3679b 100644 --- a/packages/nitro/src/runtime/hooks/captureTracingEvents.ts +++ b/packages/nitro/src/runtime/hooks/captureTracingEvents.ts @@ -23,6 +23,7 @@ import { type TracingChannelPayloadWithSpan, } from '@sentry/server-utils'; import type { TracingRequestEvent as H3TracingRequestEvent } from 'h3/tracing'; +import type { H3Event } from 'nitro/h3'; import type { RequestEvent as SrvxRequestEvent } from 'srvx/tracing'; import { setServerTimingHeaders } from './setServerTimingHeaders'; @@ -69,7 +70,7 @@ function applyResponseStatus(span: Span, data: TracingChannelPayloadWithSpan<{ r /** * Extracts the parameterized route pattern from the h3 event context. */ -function getParameterizedRoute(event: H3TracingRequestEvent['event']): string | undefined { +function getParameterizedRoute(event: H3Event): string | undefined { const matchedRoute = event.context?.matchedRoute; if (!matchedRoute) { return undefined; @@ -152,7 +153,7 @@ function setupH3TracingChannels(): void { ); h3Channel.subscribe({ - start: (data: H3TracingRequestEvent) => { + start: data => { setServerTimingHeaders(data.event); }, }); @@ -260,7 +261,7 @@ function setupSrvxTracingChannels(): void { /** * Sets the parameterized route attributes on the span. */ -function setParameterizedRouteAttributes(span: Span, event: H3TracingRequestEvent['event']): void { +function setParameterizedRouteAttributes(span: Span, event: H3Event): void { const matchedRoutePath = getParameterizedRoute(event); if (!matchedRoutePath) { return; diff --git a/packages/nitro/src/runtime/hooks/setServerTimingHeaders.ts b/packages/nitro/src/runtime/hooks/setServerTimingHeaders.ts index 4573f8171c19..8263d4c55bef 100644 --- a/packages/nitro/src/runtime/hooks/setServerTimingHeaders.ts +++ b/packages/nitro/src/runtime/hooks/setServerTimingHeaders.ts @@ -1,11 +1,11 @@ import { getTraceData } from '@sentry/core'; -import type { TracingRequestEvent as H3TracingRequestEvent } from 'h3/tracing'; +import type { H3Event } from 'nitro/h3'; /** * Sets Server-Timing response headers for trace propagation to the client. * The browser SDK reads these via the Performance API to connect pageload traces. */ -export function setServerTimingHeaders(event: H3TracingRequestEvent['event']): void { +export function setServerTimingHeaders(event: H3Event): void { if (event.context._sentryServerTimingSet) { return; } diff --git a/packages/nitro/test/runtime/hooks/captureErrorHook.test.ts b/packages/nitro/test/runtime/hooks/captureErrorHook.test.ts index f83395b6c7db..7ff08f489a0d 100644 --- a/packages/nitro/test/runtime/hooks/captureErrorHook.test.ts +++ b/packages/nitro/test/runtime/hooks/captureErrorHook.test.ts @@ -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'; diff --git a/yarn.lock b/yarn.lock index f8468387ec88..554ed736076e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16927,7 +16927,7 @@ h3@^1.10.0, h3@^1.15.10, h3@^1.15.11: ufo "^1.6.3" uncrypto "^0.1.3" -h3@^2.0.1-rc.16, h3@^2.0.1-rc.20, h3@^2.0.1-rc.22: +h3@^2.0.1-rc.16, h3@^2.0.1-rc.20: version "2.0.1-rc.22" resolved "https://registry.yarnpkg.com/h3/-/h3-2.0.1-rc.22.tgz#12c94d2f99e9afa42b490ebfda6163035e98be2a" integrity sha512-Esv0DMIuPkCTSWCA0vO73vcTqwzH1wjSrAO1TXNu/K3up1sZHa9EKMapbmxCDYBeymC3fVTk4qxp7ogQWQ+KgA==