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.
Activity
HazAT commentedon Oct 8, 2020
Thanks for reporting, would you be willing to provide a PR with the fix?
We'll try to do this tomorrow or early next week.
leemhenson commentedon Oct 8, 2020
I can, but which option do you want to take?
a) no-op the catch block if
e == nullb) ignore the callback return value and re-reject with the error
I'd lean towards b) unless there's possibly a race condition there?
HazAT commentedon Oct 8, 2020
I think b) sounds good. a) is probably easier to implement but a bit hacky