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 @@ -21,6 +21,7 @@
- ref(core): Adjust MCP server error event `mechanism` ([#17622](https://github.com/getsentry/sentry-javascript/pull/17622))
- ref(core): Simplify `linkedErrors` mechanism logic ([#17600](https://github.com/getsentry/sentry-javascript/pull/17600))
- ref(nextjs): Set more specific event `mechanism`s ([#17543](https://github.com/getsentry/sentry-javascript/pull/17543))
- 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): Add mechanism to errors captured via connect and koa integrations ([#17579](https://github.com/getsentry/sentry-javascript/pull/17579))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ test('Sends correct error event', async ({ baseURL }) => {
const errorEvent = await errorEventPromise;

expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
const exception = errorEvent.exception?.values?.[0];
expect(exception?.value).toBe('This is an exception with id 123');
expect(exception?.mechanism).toEqual({
type: 'auto.middleware.express',
handled: false,
});

expect(errorEvent.request).toMatchObject({
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ test('Sends correct error event', async ({ baseURL }) => {
const errorEvent = await errorEventPromise;

expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
const exception = errorEvent.exception?.values?.[0];
expect(exception?.value).toBe('This is an exception with id 123');
expect(exception?.mechanism).toEqual({
type: 'auto.function.fastify',
handled: false,
});

expect(errorEvent.request).toEqual({
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
});

expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an error');
const exception = errorEvent.exception?.values?.[0];
expect(exception?.value).toBe('This is an error');
expect(exception?.mechanism).toEqual({
type: 'auto.function.hapi',
handled: false,
});

expect(errorEvent.request).toEqual({
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test('withScope scope is NOT applied to thrown error caught by global handler',
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down Expand Up @@ -61,7 +61,7 @@ test('http requestisolation scope is applied to thrown error caught by global ha
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down Expand Up @@ -109,7 +109,7 @@ test('withIsolationScope scope is NOT applied to thrown error caught by global h
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('should capture and send Express controller error with txn name if tracesSa
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('should capture and send Express controller error if tracesSampleRate is no
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('should capture and send Express controller error with txn name if tracesSa
values: [
{
mechanism: {
type: 'middleware',
type: 'auto.middleware.express',
handled: false,
},
type: 'Error',
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/tracing/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErr
const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;

if (shouldHandleError(error)) {
const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });
const eventId = captureException(error, { mechanism: { type: 'auto.middleware.express', handled: false } });
(res as { sentry?: string }).sentry = eventId;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/tracing/fastify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function handleFastifyError(
}

if (shouldHandleError(error, request, reply)) {
captureException(error, { mechanism: { handled: false, type: 'fastify' } });
captureException(error, { mechanism: { handled: false, type: 'auto.function.fastify' } });
}
}

Expand Down
5 changes: 1 addition & 4 deletions packages/node/src/integrations/tracing/hapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ function isErrorEvent(event: unknown): event is RequestEvent {
function sendErrorToSentry(errorData: object): void {
captureException(errorData, {
mechanism: {
type: 'hapi',
type: 'auto.function.hapi',
handled: false,
data: {
function: 'hapiErrorPlugin',
},
},
});
}
Expand Down