Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sentry on AWS lambda in nodejs doesn't send exception

I'm trying to configure sentry on AWS Lambda (nodejs 8.10) but the exceptions are not sent to Sentry. I'm the feeling that is a issue of timing: the lambda is terminated before the data are sent to sentry.

Which is the right way to integrate sentry on AWS Lambda?

Thank you!

like image 479
aGO Avatar asked Feb 17 '19 18:02

aGO


People also ask

Does Lambda retry on exception?

If your function throws an error, the Lambda service retries your function. Since the same event may be received more than once, functions should be designed to be idempotent . This means that receiving the same event multiple times does not change the result beyond the first time the event was received.

Does AWS Lambda support node JS?

AWS Lambda now supports Node. js 16 as both a managed runtime and a container base image. Developers creating serverless applications in Lambda with Node. js 16 can take advantage of new features such as support for Apple silicon for local development, the timers promises API, and enhanced performance.


1 Answers

Update: Sentry automatically reports exceptions on Node/Lambda. see docs

You have to use the function flush which makes sure all events that are currently queued up will be sent:

Sentry.captureException(new Error('test'));
await Sentry.flush();

http://getsentry.github.io/sentry-javascript/modules/node.html#flush

like image 108
HazA Avatar answered Sep 27 '22 22:09

HazA