Node.js errors from Express routes aren't sent to Sentry

I set up Sentry in my node.js app. Sentry catches only errors explicitly sent through Sentry.captureException but errors from Express router aren’t sent.
Here is a snippet of the implementation:

const Sentry = require('@sentry/node');
const app = express(); 
Sentry.init(); //conf in .env
app.use('/api/v1', require('./app/routes'));
  shouldHandleError(error) {
    // Capture all 404 and 500 errors
    if (error.status === 404 || error.status === 500) {
      return true
    return false
app.get('/debug-sentry', function mainHandler(req, res) {
  throw new Error('My first Sentry error!');
app.get('*', (req, res) => {

Nor calling /debug-sentry or a non existing route sends an error to Sentry. Can so tells me what I’m doing wrong here?

I think shouldHandleError() might be broken. I was having the same issue but at least the /debug-sentry path works if I use the following error handler without shouldHandleError() at all:


Nothing changes for me when deleting shouldHandleError from the error handler, pretty weird…
Are there by any chance any sdk logs to investigate this issue?