Skip to content

fix(node): Ensure execArgv are not sent to worker threads #11963

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

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
includeLocalVariables: true,
transport: loggingTransport,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-unused-vars */
process.on('uncaughtException', () => {
// do nothing - this will prevent the Error below from closing this process
});

class Some {
two(name) {
throw new Error('Enough!');
}
}

function one(name) {
const arr = [1, '2', null];
const obj = {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';
const something = undefined;
const somethingElse = null;

const ty = new Some();

ty.two(name);
}

setTimeout(() => {
one('some name');
}, 1000);
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ conditionalTest({ min: 18 })('LocalVariables integration', () => {
.start(done);
});

test('Should include local variables when instrumenting via --require', done => {
const requirePath = path.resolve(__dirname, 'local-variables-instrument.js');

createRunner(__dirname, 'local-variables-no-sentry.js')
.withFlags(`--require=${requirePath}`)
.ignore('session')
.expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT })
.start(done);
});

test('Should include local variables with ESM', done => {
createRunner(__dirname, 'local-variables-caught.mjs')
.ignore('session')
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/anr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ async function _startWorker(

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

process.on('exit', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const localVariablesAsyncIntegration = defineIntegration(((
function startWorker(options: LocalVariablesWorkerArgs): void {
const worker = new Worker(new URL(`data:application/javascript;base64,${base64WorkerScript}`), {
workerData: options,
// We don't want any Node args to be passed to the worker
execArgv: [],
});

process.on('exit', () => {
Expand Down
Loading