-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
See example event here: null.<anonymous>
Package + Version
-
@sentry/serverless
Version:
5.25.0
Description
If the callback-based lambda invocation is used, as opposed to the Promise-based style, then @sentry/serverless
pushes the error correctly, but then also sends an empty exception. The reason is because this line:
captureExceptionAsync(args[0], context, options).finally(() => reject(callback(...args))); |
calls captureExceptionAsync
with the error correctly, but then also calls .finally(... reject(callback(...))
which rejects this awaited promise with undefined
(the return value of calling callback
):
? await new Promise((resolve, reject) => { |
which causes execution to drop into the catch
block below which then calls captureExceptionAsync
again, but this time passing undefined
as e
:
await captureExceptionAsync(e, context, options); |
Solution
I guess the catch
block could no-op if e === undefined
or you could change the callbackWrapper
// from:
captureExceptionAsync(args[0], context, options).finally(() => reject(callback(...args)));
// to:
callback(...args);
reject(args[0]);
as that would then push the error through the catch
block instead of the result of callback
, and would also honour the rethrow
option.