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

support Stack locals #990

Closed
grigored opened this issue Jul 5, 2017 · 7 comments
Closed

support Stack locals #990

grigored opened this issue Jul 5, 2017 · 7 comments

Comments

@grigored
Copy link

grigored commented Jul 5, 2017

Do you want to request a feature or report a bug?
feature
(If this is a usage question, please do not post it here—post it on forum.sentry.io instead. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the expected behavior?
According to the sentry docs,

In Python and PHP, Sentry will display the values of local variables at the time of each error.

Why don't we have this in js as well, and preferably also in react native? I think with the arguments variable we could log at least the locals of the function generating the exception, which would still be immensely useful.

@benvinegar
Copy link
Contributor

Why don't we have this in js as well, and preferably also in react native? I think with the arguments variable we could log at least the locals of the function generating the exception, which would still be immensely useful.

Unfortunately this isn't possible today in browser JavaScript. The arguments object is lost by the time execution enters try/catch or the onerror global error handler.

We've long experimented with making this possible, but short of re-writing your code during a compilation step to expose every conceivable variable to Raven.js (e.g. using a babel plugin) – which would make all but trivial applications pretty much unusable – there's not much we can do.

@n-peugnet
Copy link

Unfortunately this isn't possible today in browser JavaScript. The arguments object is lost by the time execution enters try/catch or the onerror global error handler.

And what about Nodejs ? Would it be possible ?

@benvinegar
Copy link
Contributor

And what about Nodejs ? Would it be possible ?

You're welcome to give it a shot – pull requests are accepted!

I've heard that it may be possible to run V8 in some kind of debugging/development mode that could expose local variables, if you wanted to start there.

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Jan 16, 2023

it's been a while since we started this convo, but we finally have support for stack locals in NodeJS. If you upgrade @sentry/node to 7.32.0 or above, you can use the LocalVariables integration to make this work.

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  includeLocalVariables: true,
});

This only works for NodeJS on v8 - not supported for other JS runtimes (yet).

@AbhiPrasad
Copy link
Member

Hey! We also released a blog post detailing how this works under the hood if anyone is curious: https://blog.sentry.io/2023/02/01/local-variables-for-nodejs-in-sentry/

@jackkinsella
Copy link

@AbhiPrasad Are there any plans to port this over to browser JavaScript? I can imagine this would be a huge hit.

@AbhiPrasad
Copy link
Member

Hey @jackkinsella unfortunately there is no way for us to access this information in the browser - we would love to support it if we could!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants