Skip to content

Commit dedc5cf

Browse files
committed
remove use of rethrowAfterCapture
1 parent 5c75be0 commit dedc5cf

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
This patch contains a breaking change for anyone setting the undocumented `rethrowAfterCapture` option for `@sentry/serverless`'s AWS wrapper to `false`, as its functionality has been removed. (That said, we couldn't find any projects in GitHub which do.) For backwards compatibility with anyone setting it to `true` (which is also the default), the option remains in the `WrapperOptions` type for now. It will be removed in the next major release, though, so we recommend removing it from your code.
8+
9+
- ref(serverless): Remove `rethrowAfterCapture` use in AWS lambda wrapper (#4448)
10+
711
## 6.17.1
812

913
- ref(core): Renormalize event only after stringification errors (#4425)
@@ -945,7 +949,7 @@ removed in the future. If you are only using the `Tracing` integration there is
945949

946950
## 5.6.3
947951

948-
- [browser] fix: Don't capture our own XHR events that somehow bubbled-up to global handler
952+
- [browser] fix: Don't capture our own XHR events that somehow bubbled-up to global handler (#2221)
949953

950954
## 5.6.2
951955

packages/serverless/src/awslambda.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export type AsyncHandler<T extends Handler> = (
4242

4343
export interface WrapperOptions {
4444
flushTimeout: number;
45-
rethrowAfterCapture: boolean;
45+
// TODO: DEPRECATED - remove `rethrowAfterCapture` in v7
46+
rethrowAfterCapture?: boolean;
4647
callbackWaitsForEmptyEventLoop: boolean;
4748
captureTimeoutWarning: boolean;
4849
timeoutWarningLimit: number;
@@ -215,11 +216,10 @@ function enhanceScopeWithEnvironmentData(scope: Scope, context: Context, startTi
215216
export function wrapHandler<TEvent, TResult>(
216217
handler: Handler<TEvent, TResult>,
217218
wrapOptions: Partial<WrapperOptions> = {},
218-
): Handler<TEvent, TResult | undefined> {
219+
): Handler<TEvent, TResult> {
219220
const START_TIME = performance.now();
220221
const options: WrapperOptions = {
221222
flushTimeout: 2000,
222-
rethrowAfterCapture: true,
223223
callbackWaitsForEmptyEventLoop: false,
224224
captureTimeoutWarning: true,
225225
timeoutWarningLimit: 500,
@@ -293,7 +293,7 @@ export function wrapHandler<TEvent, TResult>(
293293

294294
const hub = getCurrentHub();
295295
const scope = hub.pushScope();
296-
let rv: TResult | undefined;
296+
let rv: TResult;
297297
try {
298298
enhanceScopeWithEnvironmentData(scope, context, START_TIME);
299299
// We put the transaction on the scope so users can attach children to it
@@ -309,9 +309,7 @@ export function wrapHandler<TEvent, TResult>(
309309
}
310310
} catch (e) {
311311
captureException(e);
312-
if (options.rethrowAfterCapture) {
313-
throw e;
314-
}
312+
throw e;
315313
} finally {
316314
clearTimeout(timeoutWarningTimer);
317315
transaction.finish();

packages/serverless/test/awslambda.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,6 @@ describe('AWSLambda', () => {
9191
expect(Sentry.flush).toBeCalledWith(1337);
9292
});
9393

94-
test('rethrowAfterCapture', async () => {
95-
expect.assertions(3);
96-
97-
const error = new Error('wat');
98-
const handler = () => {
99-
throw error;
100-
};
101-
const wrappedHandlerWithRethrow = wrapHandler(handler, { rethrowAfterCapture: true });
102-
const wrappedHandlerWithoutRethrow = wrapHandler(handler, { rethrowAfterCapture: false });
103-
104-
await expect(wrappedHandlerWithRethrow(fakeEvent, fakeContext, fakeCallback)).rejects.toThrow(error);
105-
await expect(wrappedHandlerWithoutRethrow(fakeEvent, fakeContext, fakeCallback)).resolves.not.toThrow();
106-
expect(Sentry.flush).toBeCalledTimes(2);
107-
});
108-
10994
test('captureTimeoutWarning enabled (default)', async () => {
11095
expect.assertions(2);
11196

0 commit comments

Comments
 (0)