Nodejs Express Global error is not sending by sentry

I am trying to integrate sentry with Raven in Nodejs express. I am using promises in all of my routes and some routes are there without promises too. I setup sentry/raven as per your documentation in app.js file in nodejs.

var Raven = require(‘raven’);
var app = exports.app = express();
Raven.config(‘https://************’).install();
app.use(Raven.requestHandler());
app.use(Raven.errorHandler());

When I throw any error from the route, sentry not catching that error. But if I use Raven.captureException(e); in the code (manually) then it catches and sends the error. I want Sentry to send the errors wherever occurred in the application globally. Am I missing something in the implementation?

1 Like

That code looks fine. How do you setup your routes? Can you provide the smallest possible code example that can reproduce this issue? Also package.json dependencies list would be useful.

by default, promise rejections aren’t reported to sentry. you should set captureUnhandledRejections: true
and see if that helps
https://docs.sentry.io/clients/node/usage/#promises

1 Like