Skip to content

feat(sentry): Export withSentryConfig from @sentry/junior/nitro - #2340

Merged
dcramer merged 2 commits into
mainfrom
feat/junior-owns-sentry-nitro
Oct 29, 2026
Merged

dcramer merged 2 commits into
mainfrom
feat/junior-owns-sentry-nitro

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Junior apps no longer install @sentry/nitro themselves. @sentry/junior now depends on it, and @sentry/junior/nitro exports withSentryConfig.

The Sentry SDK keeps one client for each SDK version (globalThis.__SENTRY__[SDK_VERSION]). initSentry() creates that client with Junior's @sentry/node. If an app pins an @sentry/nitro version that differs from Junior's @sentry/node, the Nitro runtime hooks find no client. The error hook and request spans then do nothing, and nothing reports it. Before this change, each app had to keep its @sentry/nitro pin equal to the @sentry/node version inside @sentry/junior by hand.

Now @sentry/nitro and @sentry/node are next to each other in the pnpm catalog, so they get bumped together. Apps write:

import { juniorNitro, withSentryConfig } from "@sentry/junior/nitro";

withSentryConfig is a thin wrapper around the SDK function. It sets one default: the build release name is getDeploymentServiceVersion(), which is <junior version>+<VERCEL_GIT_COMMIT_SHA>. This is the same release that initSentry() reports. Without this default, @sentry/nitro names the build release after the bare commit SHA, so source maps and runtime events would be under two different releases. An explicit release.name still wins. The wrapper types come from @sentry/nitro's own signature, so dist/nitro.d.ts does not inline Nitro's types.

The apps/example app, the junior init scaffold, and the existing-app docs use the new import. The package README no longer tells apps to install @sentry/node. That instruction is how getsentry/junior-prod got an unused second copy (@sentry/node@10.49.0 next to Junior's 10.65.0).

Why now: junior-prod never adopted withSentryConfig, so production source maps are never uploaded. Production stack frames point at _libs/@sentry/junior+[...].mjs around line 226k with js_no_source. getsentry/junior-prod#568 is the draft follow-up that uses this export.

Trade-off: every Junior app now installs @sentry/nitro, @sentry/bundler-plugin-core, and @sentry/cli. @sentry/junior already hard-depends on @sentry/node, so this seemed acceptable. Without a Sentry auth token, the build logs a warning and skips the upload.

Not done here: wrapping the Sentry setup inside juniorNitro() itself. @sentry/nitro does not export the module factory for that, and it must change the config before modules run. Doing it here would mean copying SDK internals.

Verification

  • pnpm --filter @sentry/junior build: dist/nitro.js imports @sentry/nitro as an external dependency, and dist/nitro.d.ts stays small (47 lines).
  • pnpm typecheck and pnpm lint in packages/junior, and pnpm typecheck in apps/example.
  • vitest run on init-cli, check-cli, and nitro-plugin-module passed.
  • A temporary test with a mocked @sentry/nitro checked the release default. It passed 0.264.0+deadbeef when VERCEL_GIT_COMMIT_SHA was set, kept an explicit name, and left the name undefined when no SHA was set.
  • nitro build in apps/example: one @sentry/core (10.65.0) is in the output, and scripts/check-vercel-output.mjs passes.
  • pnpm build:ci in junior-prod linked to this branch: the build passes with one @sentry/core (10.65.0). The upload step ran sentry-cli releases new 0.264.0+deadbeef. The sandbox token was not authorized, so the step got a 401 and created no release.
  • pnpm release:check passes.
  • The behavioral evals failure also occurs on unrelated PRs (feat(sentry): Upgrade Sentry SDKs to v11 #2339, fix(dev): Keep evals on Blob storage and start S3 in acp-local #2328, feat(images): Generate images with GPT Image through the AI SDK #2317, fix: Update Node adapter and respect conditional watch replies #2313). The integration evals pass.
  • I did not test a real source map upload.

via Francesco Gringl-Novy.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 29, 2026 2:36pm UTC

Request Review

@sentry-evals

sentry-evals Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-behavioral

Run Status Passed Failed Errored Cost Tokens Duration
Head Error 75 2 1 $1.19 0 524.57s

Base commit 9818055 has no eval run to compare against.

junior-integration

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 102 0 0 $0.57 0 297.67s

Base commit 9818055 has no eval run to compare against.

@dcramer

dcramer commented Oct 29, 2026

Copy link
Copy Markdown
Member

this needs rebased junior

sentry-junior Bot and others added 2 commits October 29, 2026 14:34
Junior apps imported withSentryConfig from @sentry/nitro and pinned that
package themselves. The Sentry SDK keeps one client for each SDK version,
so an @sentry/nitro version that differs from Junior's @sentry/node finds
no client. Its error hook and request spans then do nothing.

@sentry/junior now depends on @sentry/nitro through the same catalog as
@sentry/node and re-exports withSentryConfig from its nitro entry. The
example app, the init scaffold, and the existing-app docs import it from
there. The package README no longer tells apps to install @sentry/node.

Co-Authored-By: Francesco Gringl-Novy <francesco.novy@sentry.io>
@sentry/nitro names the build release after the commit SHA. initSentry()
reports <junior version>+<sha>. withSentryConfig now defaults release.name
to the same value, so the uploaded source maps and runtime events use one
release. An explicit release.name still wins.
@sentry-junior
sentry-junior Bot force-pushed the feat/junior-owns-sentry-nitro branch from 74c502f to 64b6c58 Compare October 29, 2026 14:35
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Oct 29, 2026
@dcramer
dcramer merged commit e014d76 into main Oct 29, 2026
48 of 49 checks passed
@dcramer
dcramer deleted the feat/junior-owns-sentry-nitro branch October 29, 2026 15:01

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 64b6c587 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants