Skip to content

Commit 062e09d

Browse files
committed
ref(node): Adjust mechanism of express, hapi and fastify error handlers
1 parent d67b60d commit 062e09d

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

dev-packages/e2e-tests/test-applications/node-express/tests/errors.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ test('Sends correct error event', async ({ baseURL }) => {
1111
const errorEvent = await errorEventPromise;
1212

1313
expect(errorEvent.exception?.values).toHaveLength(1);
14-
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
14+
const exception = errorEvent.exception?.values?.[0];
15+
expect(exception?.value).toBe('This is an exception with id 123');
16+
expect(exception?.mechanism).toEqual({
17+
type: 'auto.middleware.express',
18+
handled: false,
19+
});
1520

1621
expect(errorEvent.request).toMatchObject({
1722
method: 'GET',

dev-packages/e2e-tests/test-applications/node-fastify-5/tests/errors.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ test('Sends correct error event', async ({ baseURL }) => {
1111
const errorEvent = await errorEventPromise;
1212

1313
expect(errorEvent.exception?.values).toHaveLength(1);
14-
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception with id 123');
14+
const exception = errorEvent.exception?.values?.[0];
15+
expect(exception?.value).toBe('This is an exception with id 123');
16+
expect(exception?.mechanism).toEqual({
17+
type: 'auto.function.fastify',
18+
handled: false,
19+
});
1520

1621
expect(errorEvent.request).toEqual({
1722
method: 'GET',

dev-packages/e2e-tests/test-applications/node-hapi/tests/errors.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
2222
});
2323

2424
expect(errorEvent.exception?.values).toHaveLength(1);
25-
expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an error');
25+
const exception = errorEvent.exception?.values?.[0];
26+
expect(exception?.value).toBe('This is an error');
27+
expect(exception?.mechanism).toEqual({
28+
type: 'auto.function.hapi',
29+
handled: false,
30+
});
2631

2732
expect(errorEvent.request).toEqual({
2833
method: 'GET',

packages/node/src/integrations/tracing/express.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErr
130130
const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
131131

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

packages/node/src/integrations/tracing/fastify/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function handleFastifyError(
132132
}
133133

134134
if (shouldHandleError(error, request, reply)) {
135-
captureException(error, { mechanism: { handled: false, type: 'fastify' } });
135+
captureException(error, { mechanism: { handled: false, type: 'auto.function.fastify' } });
136136
}
137137
}
138138

packages/node/src/integrations/tracing/hapi/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function isErrorEvent(event: unknown): event is RequestEvent {
5454
function sendErrorToSentry(errorData: object): void {
5555
captureException(errorData, {
5656
mechanism: {
57-
type: 'hapi',
57+
type: 'auto.function.hapi',
5858
handled: false,
5959
data: {
6060
function: 'hapiErrorPlugin',

0 commit comments

Comments
 (0)