Skip to content

Commit 7daca2a

Browse files
authored
Add warning about node.js bug for local variables (#6293)
1 parent 2ffce36 commit 7daca2a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/platforms/common/configuration/options.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,17 @@ _(New in version 7.30.0)_
537537

538538
Set this boolean to `true` to add stack local variables to stack traces.
539539

540+
<Alert level="warning">
541+
542+
Due to an [open Node.js issue](https://github.com/nodejs/node/issues/38439), we
543+
are currently unable to capture local variables for unhandled errors when using
544+
JavaScript modules (ESM).
545+
546+
See the <PlatformLink to="/configuration/integrations/default-integrations/#localvariables">integration
547+
options</PlatformLink> for a workaround.
548+
549+
</Alert>
550+
540551
</ConfigKey>
541552

542553
<PlatformSection supported={["javascript", "python", "node", "dart", "java", "apple"]}>

src/platforms/node/common/configuration/integrations/default-integrations.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,34 @@ Available options:
159159
captureAllExceptions?: boolean;
160160
}
161161
```
162+
<Alert level="warning">
163+
164+
Due to an [open Node.js issue](https://github.com/nodejs/node/issues/38439), we
165+
are currently unable to capture local variables for unhandled errors when using
166+
JavaScript modules (ESM).
167+
168+
You can work around this issue by wrapping your code in try/catch and
169+
enabling the `captureAllExceptions` option:
170+
171+
```javascript
172+
Sentry.init({
173+
dsn: '___PUBLIC_DSN___',
174+
integrations: [
175+
new Sentry.Integrations.LocalVariables({
176+
captureAllExceptions: true,
177+
}),
178+
],
179+
});
180+
181+
try {
182+
mainCode();
183+
} catch (e) {
184+
Sentry.captureException(e);
185+
}
186+
```
187+
188+
</Alert>
189+
162190

163191
### Modules
164192

0 commit comments

Comments
 (0)