arabold / serverless-sentry-lib

MIT License
32 stars 15 forks source link

Serverless offline / Error thrown in wrapped Handler is reported twice to sentry.io #18

Closed aheissenberger closed 4 years ago

aheissenberger commented 5 years ago

example code:

import RavenLambdaWrapper from "serverless-sentry-lib";

const ravenConfig = {
  filterLocal: false,
  captureErrors: true,
  captureUnhandledRejections: true,
  captureMemoryWarnings: true,
  captureTimeoutWarnings: true,
  ravenClient: require("raven") // don't forget!
};

export const hello = RavenLambdaWrapper.handler(
  ravenConfig,
  async (event, context) => {
    const response = {
      body: JSON.stringify({
        message: "Go Serverless v1.0! Your function executed successfully!",
        input: event
      })
    };
    throw new Error("Hallo");

    return { ...response, statusCode: 200 };
  }
);

1) catchen here and sent to sentry.io https://github.com/arabold/serverless-sentry-lib/blob/479430b9d23127a24fff2c8f54ceeba54851ca80/src/index.js#L416

2) because all context callbacks are wrapped - same error will be sent again to sentry.io https://github.com/arabold/serverless-sentry-lib/blob/479430b9d23127a24fff2c8f54ceeba54851ca80/src/index.js#L229

the wrapper will receive the error on the callback from Serverless-offline https://github.com/dherault/serverless-offline/blob/185df4d55b7f3a99a0119197c70898ded1e67434/src/index.js#L953

arabold commented 4 years ago

v2.0.0 has been released; This should not happen anymore