Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 31dc645

Browse files
authored
ref(node): Adjust mechanism of express, hapi and fastify error handlers (#17623)
Adjusts the already set mechanisms to follow the trace origin naming scheme ref ##17212
1 parent 4b562bc commit 31dc645

File tree

11 files changed

+28
-15
lines changed

11 files changed

+28
-15
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- ref(core): Adjust MCP server error event `mechanism` ([#17622](https://github.com/getsentry/sentry-javascript/pull/17622))
2222
- ref(core): Simplify `linkedErrors` mechanism logic ([#17600](https://github.com/getsentry/sentry-javascript/pull/17600))
2323
- ref(nextjs): Set more specific event `mechanism`s ([#17543](https://github.com/getsentry/sentry-javascript/pull/17543))
24+
- ref(node): Adjust mechanism of express, hapi and fastify error handlers ([#17623](https://github.com/getsentry/sentry-javascript/pull/17623))
2425
- ref(node-core): Add `mechanism` to cron instrumentations ([#17544](https://github.com/getsentry/sentry-javascript/pull/17544))
2526
- ref(node-core): Add more specific `mechanism.type` to worker thread errors from `childProcessIntegration` ([#17578](https://github.com/getsentry/sentry-javascript/pull/17578))
2627
- ref(node): Add mechanism to errors captured via connect and koa integrations ([#17579](https://github.com/getsentry/sentry-javascript/pull/17579))

‎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',

‎dev-packages/node-integration-tests/suites/express/handle-error-scope-data-loss/test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('withScope scope is NOT applied to thrown error caught by global handler',
2222
values: [
2323
{
2424
mechanism: {
25-
type: 'middleware',
25+
type: 'auto.middleware.express',
2626
handled: false,
2727
},
2828
type: 'Error',
@@ -61,7 +61,7 @@ test('http requestisolation scope is applied to thrown error caught by global ha
6161
values: [
6262
{
6363
mechanism: {
64-
type: 'middleware',
64+
type: 'auto.middleware.express',
6565
handled: false,
6666
},
6767
type: 'Error',
@@ -109,7 +109,7 @@ test('withIsolationScope scope is NOT applied to thrown error caught by global h
109109
values: [
110110
{
111111
mechanism: {
112-
type: 'middleware',
112+
type: 'auto.middleware.express',
113113
handled: false,
114114
},
115115
type: 'Error',

‎dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-0/test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('should capture and send Express controller error with txn name if tracesSa
1313
values: [
1414
{
1515
mechanism: {
16-
type: 'middleware',
16+
type: 'auto.middleware.express',
1717
handled: false,
1818
},
1919
type: 'Error',

‎dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-unset/test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('should capture and send Express controller error if tracesSampleRate is no
1414
values: [
1515
{
1616
mechanism: {
17-
type: 'middleware',
17+
type: 'auto.middleware.express',
1818
handled: false,
1919
},
2020
type: 'Error',

‎dev-packages/node-integration-tests/suites/express/handle-error/test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('should capture and send Express controller error with txn name if tracesSa
1818
values: [
1919
{
2020
mechanism: {
21-
type: 'middleware',
21+
type: 'auto.middleware.express',
2222
handled: false,
2323
},
2424
type: 'Error',

‎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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /