Repository navigation
Closed
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/tanstackstart-react
SDK Version
/
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
instrument.server.mjs
import * as Sentry from '@sentry/tanstackstart-react'
import { pinoIntegration } from '@sentry/node'
const sentryDsn = process.env.VITE_SENTRY_DSN
const appEnv = process.env.VITE_APP_ENV
const isDevelopment = process.env.NODE_ENV === 'development'
try {
if (!sentryDsn) {
console.warn('VITE_SENTRY_DSN is not defined. Sentry is not running.')
} else {
// Build integrations list - exclude profiling in development
const integrations = [
// Capture pino logs as Sentry breadcrumbs and send errors to Sentry
// https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/pino/
pinoIntegration(),
]
// Only load profiling in non-development environments
if (!isDevelopment) {
const { nodeProfilingIntegration } = await import('@sentry/profiling-node')
integrations.push(nodeProfilingIntegration())
}
Sentry.init({
dsn: sentryDsn,
// Adds request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/configuration/options/#sendDefaultPii
sendDefaultPii: false,
tracesSampleRate: 1.0,
// Set sampling rate for profiling - this is relative to tracesSampleRate
profilesSampleRate: isDevelopment ? 0 : 1.0,
profileLifecycle: 'trace',
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
enabled: !isDevelopment,
environment: appEnv,
integrations,
enableLogs: true,
})
}
}
catch (error) {
console.error('Error initializing Sentry', error)
}
package.json
{
"name": "web-app",
"private": true,
"type": "module",
"scripts": {
"dev": "dotenv -e .env.local -- sh -c \"NODE_OPTIONS='--import ./instrument.server.mjs' vite dev --port 3001\"",
"build": "vite build && cp instrument.server.mjs .vercel/server",
"build:local": "vite build && cp instrument.server.mjs .output/server",
"preview": "vite preview",
"test": "bun test",
"seed": "./scripts/seed.sh",
"seed:stripe": "./scripts/seed-stripe.sh",
"test:coverage": "bun test --coverage",
"format": "biome format --fix",
"lint": "biome lint",
"check": "biome check",
"start": "node --import ./.vercel/server/instrument.server.mjs .vercel/server/index.mjs",
"get-env": "npx vercel env pull -y --environment=${VERCEL_ENV:-development} .env.${VERCEL_ENV:-development}.local"
},
"dependencies": {
"@fontsource-variable/archivo": "catalog:ui",
"@sentry/profiling-node": "catalog:devtools",
"@sentry/tanstackstart-react": "catalog:devtools",
"@tanstack/react-devtools": "catalog:tanstack",
"@tanstack/react-query": "catalog:tanstack",
"@tanstack/react-query-devtools": "catalog:tanstack",
"@tanstack/react-router": "catalog:tanstack",
"@tanstack/react-router-devtools": "catalog:tanstack",
"@tanstack/react-router-ssr-query": "catalog:tanstack",
"@tanstack/react-start": "catalog:tanstack",
"@tanstack/router-plugin": "catalog:tanstack",
"@tailwindcss/vite": "catalog:ui",
"@vercel/analytics": "catalog:analytics",
"@workspace/auth": "*",
"@workspace/billing": "*",
"@workspace/database": "*",
"@workspace/emails": "*",
"@workspace/logger": "*",
"@workspace/seo": "*",
"@workspace/slack": "*",
"@workspace/ui": "*",
"date-fns": "catalog:date",
"date-fns-tz": "catalog:date",
"dotenv-cli": "^11.0.0",
"hono":"catalog:devtools",
"lucide-react": "catalog:ui",
"nitro": "catalog:build",
"posthog-js": "catalog:analytics",
"react": "catalog:ui",
"react-dom": "catalog:ui",
"vite-tsconfig-paths": "catalog:build"
},
"devDependencies": {
"@workspace/test-utils": "*",
"dotenv": "catalog:devtools",
"@biomejs/biome": "catalog:devtools",
"@tanstack/devtools-vite": "catalog:tanstack",
"@testing-library/dom": "catalog:testing",
"@testing-library/react": "catalog:testing",
"@types/node": "catalog:types",
"@types/react": "catalog:types",
"@types/react-dom": "catalog:types",
"@vitejs/plugin-react": "catalog:build",
"babel-plugin-react-compiler": "catalog:build",
"jsdom": "catalog:testing",
"typescript": "catalog:types",
"vite": "catalog:build",
"vitest": "catalog:build",
"web-vitals": "catalog:testing"
}
}
Steps to Reproduce
User's question:
I’m using TanStack Start with Sentry via
@sentry/tanstackstart-reactand seeing correct behavior locally, but when deploying to Vercel I don’t get any server-side issues, logs, or traces in Sentry. Client-side reporting works as expected.I’ve followed the TanStack Start + Sentry docs, including the server instrumentation setup. [[TanStack Start guide](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/#configure-server-side-sentry)]
Steps to Reproduce
- Create a new TanStack Start project.
- Install and configure
@sentry/tanstackstart-reactas above - Deploy the app to Vercel using the standard TanStack Start Vercel deployment flow.
- Trigger an error
- Check Sentry for:
- error events
- logs
- traces
Expected Result
- Server-side errors, logs, and traces appear in Sentry for the Vercel deployment, similar to local behavior.
- Manual calls like
Sentry.captureExceptionandSentry.captureMessagefrom server code should reliably show up in Sentry when deployed to Vercel.
Actual Result
- Locally:
- Server-side Sentry behavior works as expected.
- On Vercel:
- No server-side issues/logs/traces appear in Sentry.
- Client-side events still work.
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Reacted by Jared Rhizor
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsWaiting for: Support
Activity
linear commentedon Feb 20, 2026
JS-1777
masinette commentedon Feb 20, 2026
Related to: https://sentry.zendesk.com/agent/tickets/175071
JPeer264 commentedon Feb 23, 2026
Yes, this SDK is still in alpha. It is confirmed that this is not working. For the server part on Vercel, that is unfortunately harder, as Vercel doesn't allow to add the
--importflag to actually hook our instrumentations in (TanStack Start's output is ESM). The client bundle is independent of the vendor it is deployed on. I'll cross check internally if there are some workarounds for thisAxadali commentedon Feb 24, 2026
Hi @JPeer264,
I’ve been looking into this issue and wanted to share some observations:
What I think is happening:
--import ./instrument.server.mjsworks, so Sentry is initialized before any server code runs.--import, so the server-side initialization is skipped.Other considerations:
process.on('unhandledRejection')) might not persist in serverless invocations.VITE_SENTRY_DSN,VITE_APP_ENV) are needed in production.It seems like the main blocker is the inability to preload Sentry on Vercel serverless functions, which explains why server-side events don’t appear.
Just wanted to share my thoughts—hopefully this context is useful while investigating potential workarounds.
JPeer264 commentedon Feb 24, 2026
Exactly that is happening
Could you elaborate on that? Are there specifics which we could improve to make it work better for serverless lifecycles?
Axadali commentedon Feb 24, 2026
Some ways the SDK could work better for serverless:
global.__sentry_initialized__).Sentry.flush()at the end of each request to ensure errors and traces are sent.In short, making Sentry initialization and cleanup request-scoped would make it much more compatible with serverless lifecycles like Vercel’s.
JPeer264 commentedon Feb 24, 2026
Thanks for the details. We'll keep an eye on these points
nicohrubec commentedon Feb 24, 2026
We investigated this a bit more. It should work to get errors and basic tracing by importing
instrument.server.mjs(first import) inserver.tsand add aflushcall. So theserver.tsfile should look something like this: