Skip to content
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,7 @@
const Sentry = require('@sentry/node');

Sentry.init({
dsn: 'https://[email protected]/1337',
});

throw new Error('foo', { cause: 'bar' });
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ describe('OnUncaughtException integration', () => {
});
});

test('should log entire error object to console stderr', done => {
expect.assertions(2);

const testScriptPath = path.resolve(__dirname, 'log-entire-error-to-console.js');

childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stderr) => {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1).
expect(err).not.toBeNull();
const errString = err?.toString() || '';

expect(errString).toContain(stderr);

done();
});
});

describe('with `exitEvenIfOtherHandlersAreRegistered` set to false', () => {
test('should close process on uncaught error with no additional listeners registered', done => {
expect.assertions(3);
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/utils/errorhandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DEFAULT_SHUTDOWN_TIMEOUT = 2000;
*/
export function logAndExitProcess(error: Error): void {
// eslint-disable-next-line no-console
console.error(error && error.stack ? error.stack : error);
console.error(error);

const client = getCurrentHub().getClient<NodeClient>();

Expand Down