Skip to content

LocalVariables integration - re-thrown errors can completely mess up frame variables #13416

@Bruno-DaSilva

Description

@Bruno-DaSilva

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

Node v20.12.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

SDK setup:

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  includeLocalVariables: true,
});

Steps to Reproduce

  1. init sentry with the above config
  2. throw an exception
  3. catch the exception in another file or function (eg. a parent function)
  4. re-throw the error
  5. capture the re-thrown error

Expected Result

The error is reported to sentry with its ORIGINAL variables from where in was first thrown

Actual Result

The error is reported with only some frames with variables or no variables at all.

I dug into this - the error hash of the re-throw will match the error hash of the original error, and so the local variable frame state will overridden by the re-throw when the worker sends the re-throw frames. But then the re-throw location's stack and vars will not necessarily match the original frame's stack (and the re-throw's frame length may not match the error's frame) so it will effectively just null out the variables.

Metadata

Metadata

Assignees

Labels

Package: nodeIssues related to the Sentry Node SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions