Skip to content

includeLocalVariables fails to capture local variables across sync/async boundaries #11194

Closed
@andymccurdy

Description

@andymccurdy

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.103.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

    Sentry.init({
        dsn: process.env.SENTRY_DSN,
        enabled: true,
        environment: 'dev',
        includeLocalVariables: true,
        integrations: [
            Sentry.localVariablesIntegration({
              captureAllExceptions: true,
            }),
        ],
        release: version
    });

Steps to Reproduce

Full repro here: https://github.com/andymccurdy/sentry-node-koa-localvars

See README for instructions on installing and running.

I've tested on Node versions 18.19.1 and 20.11.1. Both versions produce identical behavior.

Expected Result

Local variables included in every stack frame

Actual Result

Local variables are only present on stack frames within the same async context where an error is thrown from. It is unclear if this is a symptom of #8928 or something different.

Sync Example:
sync

The request handler errorSync and the subsequent sync functions it calls (someSyncFunc, syncStepA and syncStepB) all include local variables. However, no middleware functions (Koa internal or user defined) have local variables as they are all async.

Async Example:
async

The request handler errorAsync awaits for the async function someAsyncFunc. Notice that someAsyncFunc, syncStepA and syncStepB all include local variables as they are all executed in the same tick. However no local variables are included on the errroAsync request handler as it was executed in a prior iteration of the event loop. As with the sync example, no middleware functions (Koa internal or user defined) have local 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