Repository navigation
feat(nuxt)!: Bundle server config into Nitro build - #24094
Conversation
|
bugbot run |
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 830a18a. Configure here.
chargome
left a comment
There was a problem hiding this comment.
Some questions and nits, otherwise this looks good overall!
| consoleSandbox(() => { | ||
| // eslint-disable-next-line no-console | ||
| console.log( | ||
| '[Sentry] The Sentry server SDK is already initialized, skipping a second initialization. The Sentry server config is bundled into the Nitro server build, so a `node --import` preload of the config file is no longer needed and can be removed.', |
There was a problem hiding this comment.
q: Does this correctly work in dev-mode? Just want to double check that we are not spamming the console there
| // Dev relies on runtime injection (no build-time transform), but the dev bundle hoists the ioredis | ||
| // import above the inlined `Sentry.init`, so its instrumented file loads before injection is active | ||
| // and gets no channels (5.10.x has no native ones). mysql requires its file lazily, after init. | ||
| test.skip(process.env.TEST_ENV === 'development', 'ioredis loads before runtime injection is active in dev'); |
There was a problem hiding this comment.
q: With native channels this does work right? so >5.10.x?
There was a problem hiding this comment.
Yes, this works when there are native tracing channels.
| @@ -6,6 +6,11 @@ import { waitForTransaction } from '@sentry-internal/test-utils'; | |||
| // only happens in the production build, so these tests are excluded from the | |||
There was a problem hiding this comment.
l: Stale comment with this change
…tarts (#26224) **Why:** Nitro imports the server entry lazily, in the first request. Without `node --import`, an `import './instrument.server'` in `server.ts` runs `Sentry.init()` only after that request started, so every cold start loses its `http.server` span. This follows what `@sentry/nuxt` does since #24094: the Vite plugin finds `instrument.server.{ts,mts,js,mjs}` (project root, then `src/`), bundles it into the Nitro build and loads it from a Nitro plugin, which runs when the server starts. Like Nuxt, this is always on and has no option. Orchestrion already instruments the drivers at build time, so `--import` is no longer needed in production. In `vite dev` you still need it. Existing setups keep working. A `--import` preload or an import in `server.ts` now runs `init()` a second time. The first client wins, and the SDK logs that the preload or import can be removed (Nuxt logs the same). `init()` is also skipped while TanStack Start prerenders (`TSS_PRERENDERING`), which Nuxt does too. Otherwise the bundled config would send events from the build. The `tanstackstart-react` e2e app now starts without `--import`. The whole suite passes locally that way, including the ioredis and mysql spans. `tanstackstart-react-static` keeps `--import`, so it covers existing start commands. **How to review:** Start with `src/vite/serverInstrumentation.ts`, then `init()` in `src/server/sdk.ts`. **Unsure about:** The docs still tell people to copy `instrument.server.mjs` and preload it, or to import it in `server.ts`. They need a follow-up in sentry-docs, like the Nuxt migration note. Closes JS-4051 <!-- junior-request-attribution:start --> via **Francesco Gringl-Novy**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0CA8FXFXAS%3A1794297657.485969 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0CA8FXFXAS%3A1794297657.485969) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0CA8FXFXAS%3A1794297657.485969/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Francesco Gringl-Novy <francesco.novy@sentry.io> Co-authored-by: Charly Gomez <charly.gomez1310@gmail.com>

Previously, the
sentry.server.config.tsfile was emitted in the build output so it can be added with--import. As we don't rely on early-importing anymore (thanks to orchestrion), we don't need this file anymore.Sentry.initruns at startup withoutnode --import. Works on Nitro 2 and 3, prod and dev (hurray)--importcompat: The old file path now gets a shim that just prints "remove this flag". A CI variant runs the whole suite with the shim preloaded to see if the warning is printedinitwins. The bundled init skips with a notice.listenare captured and flushed (first and last plugin slot)autoInjectServerSentrymodes, kept working until v12Closes #24149