Repository navigation
feat(studio): adopt @sentry/tanstackstart-react server instrumentation on the TanStack build - #47724
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Sentry error and performance instrumentation to the apps/studio TanStack Start runtime through server initialization, handler wrapping, global middleware, dependency registration, Vite integration, and Turbo build environment configuration. ChangesSentry instrumentation integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ServerEntry as api/server.js or serve.js
participant Instrument as instrument.server.mjs
participant Sentry as `@sentry/tanstackstart-react`
participant RawHandler as TanStack rawHandler
ServerEntry->>Instrument: import and initialize Sentry
ServerEntry->>Sentry: import wrapFetchWithSentry
ServerEntry->>RawHandler: import raw handler
ServerEntry->>Sentry: wrap rawHandler.fetch
Client->>ServerEntry: fetch request
ServerEntry->>RawHandler: invoke wrapped fetch
RawHandler-->>Client: return Response
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › table-editor.spec.ts › table editor › should show rls accordingly Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/studio/instrument.server.mjs (1)
27-44: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNext.js-specific ignore patterns in a TanStack-only file.
NEXT_NOT_FOUND/NEXT_REDIRECTare Next.js control-flow signals; this module is exclusively wired into the TanStack build (per PR objectives). These entries are inert here and appear to be a straight copy fromsentry.server.config.ts. Harmless but worth pruning for clarity.🧹 Suggested cleanup
ignoreErrors: [ 'ResizeObserver', 'Failed to load Stripe.js', - // Next.js internals — not actual errors - 'NEXT_NOT_FOUND', - 'NEXT_REDIRECT', // Network / infrastructure🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/instrument.server.mjs` around lines 27 - 44, Prune the Next.js-only ignore entries from the ignoreErrors list in instrument.server.mjs, since this module is only used for the TanStack build and those patterns are inert here. Update the ignoreErrors array in the instrumentation config to remove NEXT_NOT_FOUND and NEXT_REDIRECT, keeping the remaining non-Next.js patterns intact.apps/studio/package.json (1)
67-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueVersion pinning inconsistent with neighboring Sentry deps.
@sentry/tanstackstart-reactis exact-pinned (10.59.0) while@sentry/reactuses a caret range (^10.27.0) and@sentry/nextjsuses the workspacecatalog:. Consider aligning with the existing convention (caret range or catalog entry) unless the exact pin is intentional for this beta SDK.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/package.json` at line 67, The dependency version for `@sentry/tanstackstart-react` is pinned differently from the neighboring Sentry packages, so align its version specifier with the existing convention used in package.json. Update the `@sentry/tanstackstart-react` entry to match either the caret-range style used by `@sentry/react` or the catalog-based style used by `@sentry/nextjs`, and keep the package name entry itself as the locator for the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/studio/api/server.js`:
- Around line 17-30: The Sentry startup imports in the server bootstrap can
currently fail the whole API if `instrument.server.mjs` or
`@sentry/tanstackstart-react` throws during top-level await. Update
`apps/studio/api/server.js` to mirror the defensive pattern used in
`scripts/serve.js`: wrap the `await import('../instrument.server.mjs')` and the
`wrapFetchWithSentry` import in try/catch, keep the existing fallback
`wrapFetchWithSentry` identity function, and allow the server to continue
booting even when Sentry initialization fails.
---
Nitpick comments:
In `@apps/studio/instrument.server.mjs`:
- Around line 27-44: Prune the Next.js-only ignore entries from the ignoreErrors
list in instrument.server.mjs, since this module is only used for the TanStack
build and those patterns are inert here. Update the ignoreErrors array in the
instrumentation config to remove NEXT_NOT_FOUND and NEXT_REDIRECT, keeping the
remaining non-Next.js patterns intact.
In `@apps/studio/package.json`:
- Line 67: The dependency version for `@sentry/tanstackstart-react` is pinned
differently from the neighboring Sentry packages, so align its version specifier
with the existing convention used in package.json. Update the
`@sentry/tanstackstart-react` entry to match either the caret-range style used by
`@sentry/react` or the catalog-based style used by `@sentry/nextjs`, and keep the
package name entry itself as the locator for the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d01d0d2c-ca0f-444a-ba7c-e0741485d6b8
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (7)
apps/studio/api/server.jsapps/studio/instrument.server.mjsapps/studio/package.jsonapps/studio/scripts/serve.jsapps/studio/start.tsapps/studio/turbo.jsoncapps/studio/vite.config.ts
d0155f6 to
3f65818
Compare
09c0294 to
ebc7195
Compare
…n on the TanStack build Hybrid Sentry setup for the TanStack Start build: - Server: use the unified `@sentry/tanstackstart-react` SDK (pinned to 10.59.0 to share the single @sentry/core hub) for server instrumentation. `sentryGlobalRequestMiddleware` + `sentryGlobalFunctionMiddleware` wrap the whole request / server-function lifecycle — capturing request- and function-scoped errors, including ones downstream code swallows into a 500 that the manual `@sentry/nextjs` path never sees — and `wrapFetchWithSentry` wraps the fetch handler on both Vercel (api/server.js) and self-hosted (scripts/serve.js). `instrument.server.mjs` mirrors sentry.server.config.ts (dsn/environment/tracesSampleRate/ignoreErrors) + release for source maps. `sentryTanstackStart()` runs last in vite.config for source-map/release upload (skipped gracefully without SENTRY_AUTH_TOKEN); middleware auto-wrap is disabled since start.ts wires the middlewares explicitly. - Client: stays on `@sentry/react` (via #47666's `@sentry/nextjs` → compat shim alias). The unified SDK's browser `tanstackRouterBrowserTracingIntegration` is a no-op stub (returns undefined → TypeError), so the client keeps the verified `@sentry/react` integration. The server files import `@sentry/tanstackstart-react` directly — they only run in the SSR/Node bundle, so the broken browser export never loads. Verified the server SDK (`@sentry/node`, global middlewares) does not leak into the client bundle. - Next.js build path (instrumentation.ts / sentry.server.config.ts / next.config.ts) is untouched. Supersedes the manual `@sentry/node` server wrapper. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
- api/server.js: wrap the Sentry boot (instrument import + SDK import) in try/catch with an identity-wrapper fallback, mirroring scripts/serve.js, so a Sentry init/import failure can never take the API function down. - instrument.server.mjs: drop the Next-only NEXT_NOT_FOUND / NEXT_REDIRECT ignoreErrors entries — inert in the TanStack server runtime. - package.json: pin @sentry/tanstackstart-react via catalog (like the other @sentry packages) instead of a bare version. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
ebc7195 to
437d176
Compare
joshenlim
left a comment
There was a problem hiding this comment.
Verified changes locally! Verified that throwing an error on an API route sends an event to sentry in tanstack mode
Braintrust eval report
|
Stacked on #47666 (base
alaister/tanstack-sentry-init; retarget tomasterwhen that merges). Supersedes #47721 (the manual@sentry/nodewrapper). Client stays on #47666's@sentry/reactsetup.Adopts the official
@sentry/tanstackstart-reactSDK on the server only, after a spike (#47723) evaluating the full unified client+server SDK. The spike found the SDK's browsertanstackRouterBrowserTracingIntegrationis a broken no-op stub at 10.59.0/10.64.0 — so the client stays on@sentry/react(whose equivalent integration is a real, working implementation, already shipped in #47666). The server exports, however, are a clear upgrade and slot in cleanly.What this adds (server-side, TanStack build only)
instrument.server.mjs—Sentry.initfrom@sentry/tanstackstart-react, mirroringsentry.server.config.ts+release: VERCEL_GIT_COMMIT_SHA.start.ts—sentryGlobalRequestMiddleware+sentryGlobalFunctionMiddlewareat the front of the existingcreateStart(...)middleware. This is the win: it captures request- and server-function errors including the ones swallowed into 500s — the exact class the manual wrapper (and the Next server SDK) miss.api/server.js/scripts/serve.js— gated (STUDIO_FRAMEWORK==='tanstack') instrument init +wrapFetchWithSentryon the handler.vite.config.ts—sentryTanstackStart({ …, autoInstrumentMiddleware: false })as the last plugin: source-map upload + release injection (skips gracefully without an auth token). Middleware is wired explicitly rather than via the plugin's string-rewrite.Guarantees
@sentry/nextjs→@sentry/reactalias and fix(studio): initialize Sentry on the TanStack build (captures were silent no-ops) #47666's client init are unchanged.instrumentation.ts/sentry.server.config.tsetc. stay as-is; all new code is TanStack-gated.@sentry/node/ server middleware /wrapFetchWithSentryindist/client/assets(start.ts's server import is tree-shaken out).Verified
TanStack build exit 0 (past
assertNoChunkCycles), post-build server boot served/api/get-utc-time → 200,tsc --noEmitclean, prettier/eslint clean. Node smoke: no-DSN init is a clean no-op; wrapped handler returns 200.To test (deploy with a server DSN)
Throw a server error from an
/api/*route (or a/_serverFn/*) — including one that gets turned into a 500 without rethrowing — and confirm a server event in Sentry withrelease= the deploy SHA. Compared to #47721, the swallowed-500 case should now be captured via the middleware.Summary by CodeRabbit
New Features
Bug Fixes
Chores / Config
SKIP_ASSET_UPLOADto the build environment list to control cache/build behavior.