Skip to content

Commit 39ba7d4

Browse files
authored
fix(serverless): Don't mark all errors as unhandled (#9368)
1 parent 207b0bc commit 39ba7d4

File tree

5 files changed

+1
-70
lines changed

5 files changed

+1
-70
lines changed

packages/serverless/src/awslambda.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { performance } from 'perf_hooks';
1414
import { types } from 'util';
1515

1616
import { AWSServices } from './awsservices';
17-
import { markEventUnhandled, serverlessEventProcessor } from './utils';
17+
import { markEventUnhandled } from './utils';
1818

1919
export * from '@sentry/node';
2020

@@ -88,7 +88,6 @@ export function init(options: AWSLambdaOptions = {}): void {
8888
};
8989

9090
Sentry.init(opts);
91-
Sentry.addGlobalEventProcessor(serverlessEventProcessor);
9291
}
9392

9493
/** */

packages/serverless/src/gcpfunction/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Integration, SdkMetadata } from '@sentry/types';
33

44
import { GoogleCloudGrpc } from '../google-cloud-grpc';
55
import { GoogleCloudHttp } from '../google-cloud-http';
6-
import { serverlessEventProcessor } from '../utils';
76

87
export * from './http';
98
export * from './events';
@@ -38,5 +37,4 @@ export function init(options: Sentry.NodeOptions = {}): void {
3837
};
3938

4039
Sentry.init(opts);
41-
Sentry.addGlobalEventProcessor(serverlessEventProcessor);
4240
}

packages/serverless/src/utils.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
import { runWithAsyncContext } from '@sentry/core';
2-
import type { Event } from '@sentry/node';
32
import type { Scope } from '@sentry/types';
43
import { addExceptionMechanism } from '@sentry/utils';
54

6-
/**
7-
* Event processor that will override SDK details to point to the serverless SDK instead of Node,
8-
* as well as set correct mechanism type, which should be set to `handled: false`.
9-
* We do it like this so that we don't introduce any side-effects in this module, which makes it tree-shakeable.
10-
* @param event Event
11-
* @param integration Name of the serverless integration ('AWSLambda', 'GCPFunction', etc)
12-
*/
13-
export function serverlessEventProcessor(event: Event): Event {
14-
addExceptionMechanism(event, {
15-
handled: false,
16-
});
17-
18-
return event;
19-
}
20-
215
/**
226
* @param fn function to run
237
* @returns function which runs in the newly created domain or in the existing one

packages/serverless/test/awslambda.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -534,30 +534,5 @@ describe('AWSLambda', () => {
534534
}),
535535
);
536536
});
537-
538-
test('enhance event with correct mechanism value', () => {
539-
const eventWithSomeData = {
540-
exception: {
541-
values: [{}],
542-
},
543-
};
544-
545-
// @ts-expect-error see "Why @ts-expect-error" note
546-
Sentry.addGlobalEventProcessor.mockImplementationOnce(cb => cb(eventWithSomeData));
547-
Sentry.AWSLambda.init({});
548-
549-
expect(eventWithSomeData).toEqual({
550-
exception: {
551-
values: [
552-
{
553-
mechanism: {
554-
handled: false,
555-
type: 'generic',
556-
},
557-
},
558-
],
559-
},
560-
});
561-
});
562537
});
563538
});

packages/serverless/test/gcpfunction.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -684,30 +684,5 @@ describe('GCPFunction', () => {
684684
}),
685685
);
686686
});
687-
688-
test('enhance event with correct mechanism value', () => {
689-
const eventWithSomeData = {
690-
exception: {
691-
values: [{}],
692-
},
693-
};
694-
695-
// @ts-expect-error see "Why @ts-expect-error" note
696-
Sentry.addGlobalEventProcessor.mockImplementationOnce(cb => cb(eventWithSomeData));
697-
Sentry.GCPFunction.init({});
698-
699-
expect(eventWithSomeData).toEqual({
700-
exception: {
701-
values: [
702-
{
703-
mechanism: {
704-
handled: false,
705-
type: 'generic',
706-
},
707-
},
708-
],
709-
},
710-
});
711-
});
712687
});
713688
});

0 commit comments

Comments
 (0)