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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- ref(node): Adjust mechanism of express, hapi and fastify error handlers ([#17623](https://github.com/getsentry/sentry-javascript/pull/17623))
- ref(node-core): Add `mechanism` to cron instrumentations ([#17544](https://github.com/getsentry/sentry-javascript/pull/17544))
- ref(node-core): Add more specific `mechanism.type` to worker thread errors from `childProcessIntegration` ([#17578](https://github.com/getsentry/sentry-javascript/pull/17578))
- ref(node-core): Adjust `mechanism` of `onUnhandledRejection` and `onUnhandledException` integrations ([#17636](https://github.com/getsentry/sentry-javascript/pull/17636))
- ref(node): Add mechanism to errors captured via connect and koa integrations ([#17579](https://github.com/getsentry/sentry-javascript/pull/17579))
- ref(nuxt): Add and adjust `mechanism.type` in error events ([#17599](https://github.com/getsentry/sentry-javascript/pull/17599))
- ref(react): Add mechanism to `reactErrorHandler` and adjust mechanism in `ErrorBoundary` ([#17602](https://github.com/getsentry/sentry-javascript/pull/17602))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test('node-schedule instrumentation', async () => {
{
type: 'Error',
value: 'Error in cron job',
mechanism: { type: 'onunhandledrejection', handled: false },
mechanism: { type: 'auto.node.onunhandledrejection', handled: false },
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});

throw new Error('foo');
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as childProcess from 'child_process';
import * as path from 'path';
import { describe, expect, test } from 'vitest';
import { createRunner } from '../../../utils/runner';

describe('OnUncaughtException integration', () => {
test('should close process on uncaught error with no additional listeners registered', () =>
Expand Down Expand Up @@ -74,4 +75,30 @@ describe('OnUncaughtException integration', () => {
});
}));
});

test('sets correct event mechanism', async () => {
await createRunner(__dirname, 'basic.js')
.expect({
event: {
level: 'fatal',
exception: {
values: [
{
type: 'Error',
value: 'foo',
mechanism: {
type: 'auto.node.onuncaughtexception',
handled: false,
},
stacktrace: {
frames: expect.any(Array),
},
},
],
},
},
})
.start()
.completed();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test rejection`);
type: 'Error',
value: 'test rejection',
mechanism: {
type: 'onunhandledrejection',
type: 'auto.node.onunhandledrejection',
handled: false,
},
stacktrace: {
Expand All @@ -109,7 +109,7 @@ test rejection`);
type: 'Error',
value: 'test rejection',
mechanism: {
type: 'onunhandledrejection',
type: 'auto.node.onunhandledrejection',
handled: false,
},
stacktrace: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});

throw new Error('foo');
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as childProcess from 'child_process';
import * as path from 'path';
import { describe, expect, test } from 'vitest';
import { createRunner } from '../../../utils/runner';

describe('OnUncaughtException integration', () => {
test('should close process on uncaught error with no additional listeners registered', () =>
Expand Down Expand Up @@ -74,4 +75,30 @@ describe('OnUncaughtException integration', () => {
});
}));
});

test('sets correct event mechanism', async () => {
await createRunner(__dirname, 'basic.js')
.expect({
event: {
level: 'fatal',
exception: {
values: [
{
type: 'Error',
value: 'foo',
mechanism: {
type: 'auto.node.onuncaughtexception',
handled: false,
},
stacktrace: {
frames: expect.any(Array),
},
},
],
},
},
})
.start()
.completed();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test rejection`);
type: 'Error',
value: 'test rejection',
mechanism: {
type: 'onunhandledrejection',
type: 'auto.node.onunhandledrejection',
handled: false,
},
stacktrace: {
Expand All @@ -110,7 +110,7 @@ test rejection`);
type: 'Error',
value: 'test rejection',
mechanism: {
type: 'onunhandledrejection',
type: 'auto.node.onunhandledrejection',
handled: false,
},
stacktrace: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/lib/integrations/eventFilters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const USELESS_EXCEPTION_EVENT: Event = {
values: [
{},
{
mechanism: { type: 'onunhandledrejection', handled: false },
mechanism: { type: 'auto.node.onunhandledrejection', handled: false },
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function makeErrorHandler(client: NodeClient, options: OnUncaughtExceptio
},
mechanism: {
handled: false,
type: 'onuncaughtexception',
type: 'auto.node.onuncaughtexception',
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function makeUnhandledPromiseHandler(
},
mechanism: {
handled: false,
type: 'onunhandledrejection',
type: 'auto.node.onunhandledrejection',
},
});
});
Expand Down