Search code examples
node.jsaws-lambdasentry

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!


Solution

  • 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