Skip to content

Commit a829c3e

Browse files
timfishandreiborza
authored andcommitted
fix(node): Ensure execArgv are not sent to worker threads (#11963)
1 parent 4ed78b8 commit a829c3e

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const Sentry = require('@sentry/node');
2+
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
3+
4+
Sentry.init({
5+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6+
includeLocalVariables: true,
7+
transport: loggingTransport,
8+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable no-unused-vars */
2+
process.on('uncaughtException', () => {
3+
// do nothing - this will prevent the Error below from closing this process
4+
});
5+
6+
class Some {
7+
two(name) {
8+
throw new Error('Enough!');
9+
}
10+
}
11+
12+
function one(name) {
13+
const arr = [1, '2', null];
14+
const obj = {
15+
name,
16+
num: 5,
17+
};
18+
const bool = false;
19+
const num = 0;
20+
const str = '';
21+
const something = undefined;
22+
const somethingElse = null;
23+
24+
const ty = new Some();
25+
26+
ty.two(name);
27+
}
28+
29+
setTimeout(() => {
30+
one('some name');
31+
}, 1000);

dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ conditionalTest({ min: 18 })('LocalVariables integration', () => {
5959
.start(done);
6060
});
6161

62+
test('Should include local variables when instrumenting via --require', done => {
63+
const requirePath = path.resolve(__dirname, 'local-variables-instrument.js');
64+
65+
createRunner(__dirname, 'local-variables-no-sentry.js')
66+
.withFlags(`--require=${requirePath}`)
67+
.ignore('session')
68+
.expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT })
69+
.start(done);
70+
});
71+
6272
test('Should include local variables with ESM', done => {
6373
createRunner(__dirname, 'local-variables-caught.mjs')
6474
.ignore('session')

packages/node/src/integrations/anr/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ async function _startWorker(
156156

157157
const worker = new Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), {
158158
workerData: options,
159+
// We don't want any Node args to be passed to the worker
160+
execArgv: [],
159161
});
160162

161163
process.on('exit', () => {

packages/node/src/integrations/local-variables/local-variables-async.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export const localVariablesAsyncIntegration = defineIntegration(((
8484
function startWorker(options: LocalVariablesWorkerArgs): void {
8585
const worker = new Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), {
8686
workerData: options,
87+
// We don't want any Node args to be passed to the worker
88+
execArgv: [],
8789
});
8890

8991
process.on('exit', () => {

0 commit comments

Comments
 (0)