1

I'm using the connect-timeout module. When the timeout fires, it seems to dump the following error message to the console:

ServiceUnavailableError: Response timeout 
    at IncomingMessage.<anonymous> (/app/node_modules/connect-timeout/index.js:75:8) 
    at emitOne (events.js:96:13) 
    at IncomingMessage.emit (events.js:188:7) 
    at Timeout._onTimeout (/app/node_modules/connect-timeout/index.js:48:11) 
    at ontimeout (timers.js:365:14) 
    at tryOnTimeout (timers.js:237:5) 
    at Timer.listOnTimeout (timers.js:207:5) 

How do I suppress these log messages? I don't particularly want to see them, because the timeout firing is not really an indicator that there is a problem... it's just doing its job. And this is especially because I can add my own error handling middleware to express that can pick and choose what (if anything) to do with the error.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
drmrbrewer
  • 11,491
  • 21
  • 85
  • 181

1 Answers1

0

You need to catch this from express, the code should look like:

function errorHandler (err, req, res, next) { console.log("Oops") } app.use(errorHandler)

For more info: https://expressjs.com/en/guide/error-handling.html

  • ah OK... I was very close... I already had added an `errorHandler` function like yours (to test what it was receiving)... indeed I linked to the same docs page as you. But in my error handler I had a `next(err)`, which I supposed needs to be taken out, otherwise the error will just get passed on to the stock error handler (like at present) which will just log the message again? It's safe to leave out `next()` so that the chain stops there? The stock error handler doesn't do anything else "clever"? – drmrbrewer Mar 04 '17 at 08:50