Skip to content
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

Local Variables not being reported when hosting on Vercel #15544

Open
3 tasks done
cau777 opened this issue Feb 28, 2025 · 1 comment
Open
3 tasks done

Local Variables not being reported when hosting on Vercel #15544

cau777 opened this issue Feb 28, 2025 · 1 comment
Labels
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

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

No branches or pull requests

2 participants