Skip to content

TanStack Start + Vercel: No server-side errors/logs/traces with @sentry/tanstackstart-react (alpha) #19458

@masinette

Description

@masinette

Is there an existing issue for this?

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-react and 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

  1. Create a new TanStack Start project.
  2. Install and configure @sentry/tanstackstart-react as above
  3. Deploy the app to Vercel using the standard TanStack Start Vercel deployment flow.
  4. Trigger an error
  5. 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.captureException and Sentry.captureMessage from 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions