Giter VIP home page Giter VIP logo

Comments (8)

arabold avatar arabold commented on May 27, 2024 1

Thanks for reporting and providing an example. Indeed I'm able to reproduce this issue now and will release a fix shortly.

from serverless-sentry-plugin.

arabold avatar arabold commented on May 27, 2024

Thanks for the report. I haven't used serverless-http myself. Possibly another component overwrites the unhandled rejection handler. Do you have a minimal example that reproduces the issue?

from serverless-sentry-plugin.

ffxsam avatar ffxsam commented on May 27, 2024

@arabold Hey, sorry for the delay! Been a bit busy.

Here's a reproduction: https://github.com/ffxsam/repro-err-handling

When I deploy this to AWS and curl the API endpoint, I get this response:

{"message": "Internal server error"}

But there are no error reports in Sentry.

from serverless-sentry-plugin.

ffxsam avatar ffxsam commented on May 27, 2024

(don't forget to change the DSN in serverless.yml)

from serverless-sentry-plugin.

ffxsam avatar ffxsam commented on May 27, 2024

@arabold No way.. awesome! Thanks, I really appreciate that!

from serverless-sentry-plugin.

ffxsam avatar ffxsam commented on May 27, 2024

Promises can get tricky when they're several levels deep. I'm very curious to see the solution to this problem.

from serverless-sentry-plugin.

arabold avatar arabold commented on May 27, 2024

I have published v2.3.0 of the serverless-sentry-lib. An update to the plugin is not necessary, just the lib. This should fix the reporting of both unhandled rejections and uncaught exceptions.

The lib handles two cases now (based on your serverless-http example):

// Throw an unhandled rejection
router.get("/test1", (req, res) => {
  new Promise((resolve, reject) => {
    reject("Reject this!");
  });
  res.json({ success: true });
});

// Throw an uncaught exception
router.get("/test2", function (req, res, next) {
  setImmediate(() => {
    throw new Error("Catch this!");
  });
  res.json({ success: true });
});

There's a third case that is handled by Express automatically. You can register a custom error handling middleware that forwards errors to Sentry in this case as well:

router.get("/test2", async (req, res) => {
  throw new Error("Catch this!");
  res.json({
    success: true,
  });
});

router.use(function (err, req, res, next) {
  Sentry.captureException(err);
  res.json({ message: error.message });
});

Hope this solves all issues for you. Please let me know if you encounter anything else!

from serverless-sentry-plugin.

ffxsam avatar ffxsam commented on May 27, 2024

Amazing, thank you!

from serverless-sentry-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.