Skip to content

Local Variables not being reported when hosting on Vercel #15544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
cau777 opened this issue Feb 28, 2025 · 5 comments
Open
3 tasks done

Local Variables not being reported when hosting on Vercel #15544

cau777 opened this issue Feb 28, 2025 · 5 comments
Labels
Bug Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@cau777
Copy link

cau777 commented Feb 28, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

9.2.0

Framework Version

Next 15.2.0

Link to Sentry event

https://aerial-ops.sentry.io/issues/6340230618/events/4b04a367762c4da59f3ffc5d112adccb/?project=6255059

Reproduction Example/SDK Setup

GitHub repo: https://github.com/cau777/temp-sentry-nextjs-localvars

Steps to Reproduce

  1. Create a NextJS project using create-next-app: npx create-next-app@latest temp-sentry-nextjs-localvars
  2. Install Sentry with the wizard: npx @sentry/wizard@latest -i nextjs
  3. Add includeLocalVariables: true to sentry.server.config.ts
  4. Implement a test function under pages/api, for example:
const willThrow = () => {
  const hey = 12
  const value = 1
  const str = "some string"
  console.log(hey, value, str)
  throw new Error("Intentional error on Sentry reproduction 3")
}

export default function handler(_req, res) {
  try {
    willThrow()
  } catch (e) {
    captureException(e)
  }

  res.status(200).json({ name: "John Doe" });
}
  1. Upload the project to a git repo and deploy to Vercel
  2. Add SENTRY_AUTH_TOKEN to the env variables in Vercel

Expected Result

When navigating to the test API route on the deployed app, an error should be reported to Sentry, containing all 3 local variables from the willThrow function.

Actual Result

No local variables appear in the Sentry issue when the app is deployed on Vercel.

Image

However, running the same code locally npm run dev reports local variables to Sentry as expected.

https://aerial-ops.sentry.io/issues/6340144143/events/d4f46bc86efa400db9fac4c8c8f5e8c1/?project=6255059

Image

Vercel apps are deployed on AWS Lambda, maybe the debugger used by Sentry to extract local variables doesn't work in that environment?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 28, 2025
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Feb 28, 2025
@AbhiPrasad
Copy link
Member

If you set debug: true in your Sentry.init call in sentry.server.config.ts what gets logged out? You'll also have to set disableLogger: false in your next.config.js

https://github.com/cau777/temp-sentry-nextjs-localvars/blob/62917bc2127414f1ff5035fb250a881c0155bbb8/next.config.ts#L37

@cau777
Copy link
Author

cau777 commented Mar 3, 2025

Thanks for the quick response!

If I enable debug and call my test API route, the following gets logged on Vercel:

Vercel logs
10:11:13.498 Sentry Logger [log]: [Tracing] Starting sampled root span
  op: < unknown op >
  name: GET /api/sentry-example-api
  ID: a853a0e5b0851b17
10:11:15.297 Sentry Logger [debug]: @sentry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'http' }
10:11:15.300 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'http' }
10:11:15.406 Sentry Logger [debug]: @sentry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'https' }
10:11:15.406 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'https' }
10:11:17.002 Sentry Logger [log]: [Tracing] Inheriting parent's sampled decision for executing api route (pages) /api/sentry-example-api: true
10:11:17.003 Sentry Logger [log]: [Tracing] Starting sampled span
  op: < unknown op >
  name: executing api route (pages) /api/sentry-example-api
  ID: f382ac998523307f
  parent ID: a853a0e5b0851b17
  root ID: a853a0e5b0851b17
  root description: GET /api/sentry-example-api
10:11:17.548 Sentry Logger [info]: Starting a new trace with id 03123b1f08c7449fb7367759c8049cac
10:11:17.603 Sentry Logger [log]: [Tracing] Starting sampled root span
  op: http.server
  name: GET /api/sentry-example-api
  ID: 52aae385bcddda71
10:11:17.604 12 1 some string
10:11:17.653 Sentry Logger [log]: Captured error event `Intentional error on Sentry reproduction 3`
10:11:17.677 Sentry Logger [log]: [Tracing] Finishing "http.server" root span "GET /api/sentry-example-api" with ID 52aae385bcddda71
10:11:17.678 Sentry Logger [log]: Flushing events...
10:11:17.765 Sentry Logger [log]: SpanExporter exported 1 spans, 0 spans are waiting for their parent spans to finish
10:11:17.781 Sentry Logger [log]: Flushing outcomes...
10:11:17.781 Sentry Logger [log]: No outcomes to send
10:11:17.782 Sentry Logger [log]: [Tracing] Finishing "< unknown op >" span "executing api route (pages) /api/sentry-example-api" with ID f382ac998523307f
10:11:17.783 Sentry Logger [log]: [Tracing] Finishing "< unknown op >" root span "GET /api/sentry-example-api" with ID a853a0e5b0851b17
10:11:17.858 Sentry Logger [log]: SpanExporter exported 2 spans, 0 spans are waiting for their parent spans to finish
10:11:17.942 Sentry Logger [debug]: Instrumentation suppressed, returning Noop Span
10:11:17.943 Sentry Logger [log]: [Tracing] Not injecting trace data for url because tracing is suppressed.
10:11:17.943 Sentry Logger [debug]: @sentry/instrumentation-http http instrumentation for outgoing requests
10:11:17.989 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http https instrumentation outgoingRequest
10:11:18.004 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http http.ClientRequest return request
10:11:18.004 Sentry Logger [log]: Event processor "NextLowQualityTransactionsFilter" dropped event
10:11:18.004 Sentry Logger [log]: Recording outcome: "event_processor:transaction"
10:11:18.088 Sentry Logger [log]: An event processor returned `null`, will not send event.
10:11:18.104 Sentry Logger [debug]: Instrumentation suppressed, returning Noop Span
10:11:18.105 Sentry Logger [log]: [Tracing] Not injecting trace data for url because tracing is suppressed.
10:11:18.105 Sentry Logger [debug]: @sentry/instrumentation-http http instrumentation for outgoing requests
10:11:18.108 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http https instrumentation outgoingRequest
10:11:18.117 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http http.ClientRequest return request
10:11:18.120 Sentry Logger [debug]: Instrumentation suppressed, returning Noop Span
10:11:18.120 Sentry Logger [log]: [Tracing] Not injecting trace data for url because tracing is suppressed.
10:11:18.120 Sentry Logger [debug]: @sentry/instrumentation-http http instrumentation for outgoing requests
10:11:18.122 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http https instrumentation outgoingRequest
10:11:18.122 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http http.ClientRequest return request
10:11:18.151 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on response()
10:11:18.165 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on end()
10:11:18.165 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on request close()
10:11:18.165 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on response()
10:11:18.166 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on end()
10:11:18.169 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on request close()
10:11:18.170 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on response()
10:11:18.172 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on end()
10:11:18.172 Sentry Logger [debug]: @opentelemetry_sentry-patched/instrumentation-http outgoingRequest on request close()
10:11:18.172 Sentry Logger [log]: Done flushing events
10:11:18.726 [LocalVariables Worker] Connected to main thread

Perhaps the problem is that [LocalVariables Worker] Connected to main thread happens after the function is called and the Sentry event is flushed?

Also, I expected to find Debugger listening on ws://[...] in the Vercel logs, but there were no SDK startup logs.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 3, 2025
@AbhiPrasad
Copy link
Member

something in the vercel serverless environment is causing a delay in the worker to be initialized. I wonder if there is a problem with importing and using the inspector.

Going to backlog this as a confirmed bug.

@nicolassanmar
Copy link

Thanks! I'm also encountering the same issue.
Do you have any estimate about when you are going to tackle this issue?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 12, 2025
@Lms24
Copy link
Member

Lms24 commented Mar 13, 2025

Hey, I'm afraid we don't have an estimate right now. Though we're in bug-bashing mode so we might get to it soon (TM). Unfortunately, fixing stuff on platforms like Vercel isn't always easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Status: No status
Development

No branches or pull requests

5 participants