uncaughtException not called with http.get()

  • Version: v5.7.1
  • Platform: Darwin 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
  • Subsystem: http, errors

With the following example, I would expect uncaughtException to be triggered. It works on v4.x but not on latest v5.

var http = require('http')

process.once('uncaughtException', function(error) {
  console.log('in uncaughtException')
  console.log(error)
})

server = http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'})
  res.end('some data')
})

server.listen(8183, function () {
  http.get('http://localhost:8183', function (res) {
    console.log('got response')
    res.resume()

    // throwing error here to trigger uncaughtException
    throw new Error("some error")
  })
})