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

Can't see local variables on the sentry dashboard #13394

Open
3 tasks done
CaptainStiggz opened this issue Aug 15, 2024 · 2 comments
Open
3 tasks done

Can't see local variables on the sentry dashboard #13394

CaptainStiggz opened this issue Aug 15, 2024 · 2 comments
Assignees
Labels
Feature: Errors Package: node Issues related to the Sentry Node SDK Type: Documentation

Comments

@CaptainStiggz
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.26.0

Framework Version

No response

Link to Sentry event

https://visualelectric.sentry.io/share/issue/280ad0165d0b4e7f985ac7c5b26e7069/

Reproduction Example/SDK Setup

I can't see local variables logged in the sentry dashboard for my project.

Minimal example:

// test.js
import dotenv from 'dotenv'

if (process.env.NODE_ENV !== 'production') {
  dotenv.config({ path: '../.env' })
}
import * as Sentry from '@sentry/node'

Sentry.init({
  release: process.env.VE_SENTRY_RELEASE,
  dsn: process.env.VE_SERVER_SENTRY_DSN,
  environment: process.env.VE_ENVIRONMENT,
  includeLocalVariables: true,
})

function run() {
  console.log('test local vars...')
  const someVariable1 = undefined
  const someVariable2 = 2
  console.log(someVariable1.test)
}

run()

Steps to Reproduce

node test.js on the above example

Expected Result

I expect to be able to see the values of someVariable1 and someVariable2 in the sentry dashboard for the issue.

Actual Result

Image

@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Aug 15, 2024
@AbhiPrasad
Copy link
Member

Hey @CaptainStiggz.

As per https://docs.sentry.io/platforms/javascript/guides/node/configuration/options/#include-local-variables

Due to an open Node.js issue, we are currently unable to capture local variables for unhandled errors when using JavaScript modules (ESM).

To get around this, you'll need to explicity call Sentry.captureException in a try - catch if you are using ESM.

If you use one of our framework error handlers (setupExpressErrorHandler, setupFastifyErrorHandler) we call captureException in the request middleware, so local variables will be attached in esm.

@AbhiPrasad
Copy link
Member

We need to improve our docs here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Errors Package: node Issues related to the Sentry Node SDK Type: Documentation
Projects
Status: No status
Development

No branches or pull requests

2 participants