Repository navigation
feat(nitro): Register sentry.server.config as a Nitro plugin from the Vite and Rollup plugins - #26858
Closed
sentry-junior[bot] wants to merge 2 commits into
Closed
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
… Vite and Rollup plugins
The plugins' Nitro hook finds `sentry.server.config.{ts,js,mjs,cjs,mts,cts}`
in Nitro's root directory, or the file from the new `serverConfigFile`
option, and registers it as the first Nitro plugin through a virtual module
that imports it. Users then need no `definePlugin`, no `serverDir` and no
preloaded `instrument.mjs` to get `Sentry.init()` into Nitro's process.
Co-Authored-By: Francesco Gringl-Novy <[email protected]>
…o-sentry-server-config Co-Authored-By: Francesco Gringl-Novy <[email protected]>
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 68 successful. See the run.
Successful checks
|
Contributor
size-limit report 📦Compared: 0be6d5b (PR test merge using feat/nitro-orchestrion-prepare-response at 75ec498) Against: 638a964 (feat/nitro-orchestrion-prepare-response) · base run #67714
|
Contributor
Author
|
Closing: #24900 now plans a dedicated Nitro module ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Nitro apps with
@sentry/nodeand its Vite or Rollup plugin putSentry.init()in asentry.server.config.tsnext to their Nitro or Vite config, like in Nuxt. The plugins register it as the first Nitro plugin, with nodefinePlugin,serverDiror preloadedinstrument.mjsneeded. A newserverConfigFileoption points to a different file, or turns this off withfalse.The
node-nitro-3e2e app now uses a baresentry.server.config.ts.Why
Part of #24900, stacked on #26809. Nitro only scans
<serverDir>/plugins/whenserverDiris set, and Nitro 3 defaults it tofalse. So a hand-written Nitro plugin needs extra config, and a preloadedinstrument.mjsalso runs in the dev server in front of Nitro's worker.The registration happens in the same Nitro hook that turns on the tracing channels. The wrapper is a virtual module that the plugins resolve themselves, with the file path in its id, so any plugin instance can load it. Putting it first means
Sentry.init()runs before the user's own Nitro plugins, including the ones Nitro scans fromplugins/.Open decisions:
buildTimeInstrumentation: falsestill returns the inert plugin, so it registers nothing. That's consistent with the tracing channels, but it meansSentry.init()silently doesn't run.serverConfigFileis a working name. It's top-level onsentryVitePluginandsentryRollupPlugineven though only Nitro reads it.via @mydea.
--
View Session [Sentry]