Skip to content

support Stack locals #990

@grigored

Description

@grigored

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.

Activity

benvinegar

benvinegar commented on Jul 21, 2017

@benvinegar
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

n-peugnet commented on Jun 27, 2019

@n-peugnet

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

benvinegar commented on Jun 27, 2019

@benvinegar
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

AbhiPrasad commented on Jan 16, 2023

@AbhiPrasad
Member

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

AbhiPrasad commented on Feb 6, 2023

@AbhiPrasad
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

jackkinsella commented on Apr 24, 2024

@jackkinsella

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

AbhiPrasad

AbhiPrasad commented on Apr 24, 2024

@AbhiPrasad
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @benvinegar@jackkinsella@grigored@AbhiPrasad@n-peugnet

        Issue actions

          support Stack locals · Issue #990 · getsentry/sentry-javascript