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!
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With