Skip to content

Commit 353eff4

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

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ describe('AWSLambda', () => {
9191
expect(Sentry.flush).toBeCalledWith(1337);
9292
});
9393

94+
// TODO: DEPRECATED - remove in v7
9495
test('rethrowAfterCapture', async () => {
9596
expect.assertions(3);
9697

0 commit comments

Comments
 (0)