Skip to content

fix(nuxt): Keep @sentry/server-runtime-injection external on Nitro v3 - #24901

Merged
mydea merged 1 commit into
developfrom
fix/nuxt-5-runtime-injection-external
Oct 12, 2026
Merged

mydea merged 1 commit into
developfrom
fix/nuxt-5-runtime-injection-external

Conversation

@mydea

@mydea mydea commented Sep 30, 2026

Copy link
Copy Markdown
Member

On Nuxt 5 (Nitro v3) with Node < 24.13, server startup logged Failed to register diagnostics-channel injection hooks. Nitro v3 bundles every dependency, including @sentry/server-runtime-injection. Without Module.registerHooks, it registers its ESM loader hook through Module.register, which needs hook.js on disk. The bundled copy has no such file, and the fallback @sentry/server-runtime-injection/hook specifier can't resolve because the output has no node_modules. Node 24.13+ takes the registerHooks path and was unaffected, as were Nuxt 3/4, since Nitro v2 keeps dependencies external.

The fix adds the package to Nitro's traceDeps, so it ships in .output/server/node_modules. Note that a Nuxt app with a local module still gets it bundled: Nuxt adds the app root to build.transpile, which Nitro v3 turns into an unanchored noExternals pattern. The traced copy still makes the fallback specifier resolve, so registration works there too.

The e2e runner uses Node 24, so the nuxt-5 regression test asserts the hook specifier resolves from the server output rather than checking for the missing warning. The warning now also includes the underlying error, which previously only showed with debug: true.

🤖 Generated with Claude Code

@mydea
mydea requested a review from s1gr1d September 30, 2026 14:57
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.82 kB - -
@sentry/browser - with treeshaking flags 27.95 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.86 kB - -
@sentry/browser (incl. Tracing) 51.88 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.9 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.83 kB - -
@sentry/browser (incl. Tracing, Replay) 91.63 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.49 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.34 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.32 kB - -
@sentry/browser (incl. Feedback) 47.34 kB - -
@sentry/browser (incl. sendFeedback) 34.87 kB - -
@sentry/browser (incl. FeedbackAsync) 39.98 kB - -
@sentry/browser (incl. Metrics) 30.84 kB - -
@sentry/browser (incl. Logs) 31.13 kB - -
@sentry/browser (incl. Metrics & Logs) 31.77 kB - -
@sentry/react 31.65 kB - -
@sentry/react (incl. Tracing) 54.21 kB - -
@sentry/vue 37.89 kB - -
@sentry/vue (incl. Tracing) 54.81 kB - -
@sentry/svelte 29.84 kB - -
@sentry/remix (Remix 3 client bundle) 56.91 kB - -
CDN Bundle 31.55 kB - -
CDN Bundle (incl. Tracing) 52.41 kB - -
CDN Bundle (incl. Logs, Metrics) 33.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.34 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.67 kB - -
CDN Bundle (incl. Tracing, Replay) 90.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.18 kB - -
CDN Bundle - uncompressed 92.91 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.53 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.48 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.48 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.7 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.33 kB - -
@sentry/nextjs (client) 56.62 kB - -
@sentry/sveltekit (client) 52.27 kB - -
@sentry/core/server 40.92 kB - -
@sentry/core/browser 13.74 kB - -
@sentry/node 151.9 kB +0.02% +22 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.78 kB +0.02% +13 B 🔺
@sentry/node - without tracing 94.46 kB +0.02% +16 B 🔺
@sentry/node - without channel injection 130.09 kB +0.01% +8 B 🔺
@sentry/aws-serverless 102.63 kB +0.02% +14 B 🔺
@sentry/cloudflare (withSentry) - minified 210.2 kB - -
@sentry/cloudflare (withSentry) 521.15 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 227.87 kB - -

View base workflow run

@mydea
mydea marked this pull request as ready for review October 1, 2026 06:26
@mydea
mydea requested review from a team as code owners October 1, 2026 06:26
@mydea
mydea requested review from JPeer264, isaacs and nicohrubec and removed request for a team October 1, 2026 06:26
Nitro v3 bundles every dependency, including `@sentry/server-runtime-injection`.
On Node versions without `Module.registerHooks` (< 24.13), it registers its ESM
loader hook through `Module.register`, which needs the hook file on disk. The
bundled copy has none, and the fallback package specifier cannot resolve without
`node_modules` in the output, so registration failed with a warning.

Add the package to Nitro's `traceDeps` so it ships in `.output/server/node_modules`.
Also include the underlying error in the registration failure warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea
mydea force-pushed the fix/nuxt-5-runtime-injection-external branch from 71a0596 to d1543c5 Compare October 12, 2026 13:14
@mydea
mydea merged commit 1e86178 into develop Oct 12, 2026
514 of 516 checks passed
@mydea
mydea deleted the fix/nuxt-5-runtime-injection-external branch October 12, 2026 14:06
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.

2 participants