Skip to content

Commit 99e6264

Browse files
committed
remove rethrowAfterCapture option
1 parent 5c75be0 commit 99e6264

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

packages/serverless/src/awslambda.ts

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

4343
export interface WrapperOptions {
4444
flushTimeout: number;
45-
rethrowAfterCapture: boolean;
4645
callbackWaitsForEmptyEventLoop: boolean;
4746
captureTimeoutWarning: boolean;
4847
timeoutWarningLimit: number;
@@ -215,11 +214,10 @@ function enhanceScopeWithEnvironmentData(scope: Scope, context: Context, startTi
215214
export function wrapHandler<TEvent, TResult>(
216215
handler: Handler<TEvent, TResult>,
217216
wrapOptions: Partial<WrapperOptions> = {},
218-
): Handler<TEvent, TResult | undefined> {
217+
): Handler<TEvent, TResult> {
219218
const START_TIME = performance.now();
220219
const options: WrapperOptions = {
221220
flushTimeout: 2000,
222-
rethrowAfterCapture: true,
223221
callbackWaitsForEmptyEventLoop: false,
224222
captureTimeoutWarning: true,
225223
timeoutWarningLimit: 500,
@@ -293,7 +291,7 @@ export function wrapHandler<TEvent, TResult>(
293291

294292
const hub = getCurrentHub();
295293
const scope = hub.pushScope();
296-
let rv: TResult | undefined;
294+
let rv: TResult;
297295
try {
298296
enhanceScopeWithEnvironmentData(scope, context, START_TIME);
299297
// We put the transaction on the scope so users can attach children to it
@@ -309,9 +307,7 @@ export function wrapHandler<TEvent, TResult>(
309307
}
310308
} catch (e) {
311309
captureException(e);
312-
if (options.rethrowAfterCapture) {
313-
throw e;
314-
}
310+
throw e;
315311
} finally {
316312
clearTimeout(timeoutWarningTimer);
317313
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)