-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
@sentry/node
with includeLocalVariables
is not showing anything about local variables on any errors on the Sentry dashboard
#8928
Comments
@sentry/node
with includeLocalVariables
is not showing local variables with errors@sentry/node
with includeLocalVariables
is not showing anything about local variables on any errors on the Sentry dashboard
This comment was marked as outdated.
This comment was marked as outdated.
+1 |
Interesting. And what about should/could local variables be included in exceptions caught by the Sentry Express integration, i.e. |
@ruohola Hi, what node version are you using? Did you turn on the |
I'm using Node 18.15.0 as pointed out in opening. No, I did not yet enable |
If it is possible, yes that would make sense, however, it is likely not. The idea is not bad. Node does not provide a dedicated API to grab local variables in the current scope, but it is possible with Node.js' debugger/inspector API, which we are leveraging here. If you think it through, you can't retroactively tell the debugger to grab the local variable state as it was when an error was thrown. However, that's exactly what we would need to do, in order to make what you suggest happen. I scanned the debugger API and couldn't find a way (maybe I missed something though). For the above reason, we need this all-or-nothing option. Either we can grab the variables in time, or we don't at all.
We thought people might not wanna have this on by default since this obviously impacts performance, so we added this option. Makes sense I think. This is addon functionality, not essential for the SDK to work. Feel free to leave it turned off. In case you care about the technical details feel free to take a look at our code for this functionality. It is all within one file!
|
The overhead caused by this really does vary from app to app, I would advise profiling in more detail if you're really interested in using this! Perhaps even with extra throwing the overhead is worthwhile to get extra debugging context. |
I've opened a PR to add rate limiting for capturing caught exceptions. This should make it safe to enable for all: |
We've released changes to make capturing local variables for all errors (handled and unhandled) the default in https://github.com/getsentry/sentry-javascript/releases/tag/7.73.0 |
After upgrading to |
Maybe someone has an example of code that works with |
It works with all the integration tests. Do you have a simplified example of it not working? |
"@sentry/node": "^7.101.1" Example
|
I suspect this might be an issue with the top level scope. @maximlopin2 if you put all the logic into a function, does local variables show up? function run() {
const someVariable1 = 1
try {
const someVariable2 = 2
unknownFunction()
} catch (e) {
Sentry.captureException(e)
}
}
run(); |
Yes, now it at least shows one of the variables 🤔 |
@maximlopin2 I think that is as good as it gets for now 🤔 @timfish we need a stack frame to match stuff right? Maybe there's an issue with top level calls. Also @maximlopin2 are just doing plain Node.js code or ts-node or something like that. I am thinking that the runtime optimized |
I'll add some tests for top level capture and see if we can add any special handling for that. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
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
7.64.07.73.0Framework Version
Node 18.15.0
Link to Sentry event
[private]
SDK Setup
Steps to Reproduce
I'm trying to use
@sentry/node
's newincludeLocalVariables
(https://blog.sentry.io/local-variables-for-nodejs-in-sentry/).I'm using Sentry SDK 7.73.0 with Node 18.15.0 (TypeScript, without ESM modules), which should work fine. But my caught errors do not show any local variables in the Sentry Dashboard.
Expected Result
Each caught error would the values of show local variables as such on the Sentry dashboard (picture from the blog post):
Actual Result
The errors show up fine as before, but no local variables can be seen anywhere from the dashboard:
┆Issue is synchronized with this Jira Improvement by Unito
The text was updated successfully, but these errors were encountered: