Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Thrown errors not logged in express #24

Starefossen opened this Issue · 14 comments

7 participants



Currently in the works of setting up a Node.JS application using Express.JS and Sentry for error logging. However, only uncaught errors seams to be logged if I use client.patchGlobal() otherwise thrown errors are only printed to the command line and Sentry never gets them. Yes, I run the server in production mode.

Tested on:
Node.JS: v0.8.19
Express.JS: v3.1.0
raven-node: v0.4.6


Can you send an example of what you're doing? Things aren't that obviously broken. :)


I agree with you @mattrobenolt; I have however searched all the available resources and tried a lot of examples with no different results than my own. Here is my app it only prints stack trace to the console.

"use strict"

http    = require 'http'
express = require 'express'
app     = express()
raven   = require 'raven'

app.use express.bodyParser()
app.get '/', (req, res) ->
  res.send 'Hello World'
  throw new Error 'Broke!'


app.listen 3000
console.log 'Server is running on port 3000'

Starting the server:

NODE_ENV=production node myapp.js

Did you ever figure it out? I've been having the same problem (with basically the same code). The app only prints the stack trace to console and Sentry doesn't get it.


I honestly don't know enough about how Express or these things work, so if you have any ideas, I'm open to checking them out.


Hmmmm did you next() your errors on your express routes?

--- edited ---

Can you try something like:

app.get('/', function(req, res, next) {
   res.send('Hello World');
   next(new Error("Bump!"));

Ah, I figured out my problem. I needed to add app.use(app.router) BEFORE app.user( This is basically what another pull request is talking about #45


@mstorus Do the instructions in that PR fix the issue? Like I said, I'm far from knowledgeable with Express, so.... :)


If you are using connect or express I recommend using the following module instead:

I use express all the time and leverage this module constantly.


I'm having this issue as well. Currently using express 3.xx and raven 0.6.3


@jpanganiban Any more information other than... "I'm having this issue as well."? Since the original issue was just user error.


@mattrobenolt: I'm using the express middleware with raven:


// And somewhere below...
app.get('/test', function(req, res) {
  res.json(x);  // an exception should be thrown

No events are being sent to sentry. Also, I'm on NODE_ENV=production.

EDIT: Snap. It's working now. Must be my internet connection. :)) Thanks guise!


Here is an update for express 4

the line: app.use('XXXX'));

must now appear AFTER routing rules app.get() because middleware and paths are called in the order they were declared.



@mattrobenolt - can you please update the README ?


wtf, that's a super shitty change.

@namel if you want to submit a pull request, I'll take that. Otherwise, I'll likely look at it and update later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.