Closed
Description
- Version: 12.16.0 | 13.8.0
- Platform: Darwin Kernel Version 18.6.0
- Subsystem:
What steps will reproduce the bug?
Throwing from a response listener (callback) to http.get()
will not trigger process.once('uncaughtException', () => {})
. Interestingly, throwing from a request listener (callback) to http.createServer()
will still.
This behavior changed with 12.16.0, I'm guessing likely due to the porting of the emit changes?
const http = require('http')
let server
let request
process.once('uncaughtException', function() {
// never gets here from response listener in 12.16, works fine < 12.16.
console.log('in uncaughtException handler')
server.close(done)
})
server = http.createServer(function cb_createServer(request, response) {
// Throw from request listener will result in uncaughtException
//throw new Error('wat')
response.writeHead(200, {'Content-Type': 'text/plain'})
response.end()
})
server.listen(8183, function() {
request = http.get({host: 'localhost', port: 8183}, function() {
// Throw from response listener will not result in uncaughtException
throw new Error('whoah')
})
})
How often does it reproduce? Is there a required condition?
Consistently does not trigger uncaughtException
/ does not allow handling via process.on('uncaughtException', ...)
.
What is the expected behavior?
Should be able to notice the uncaught exception thrown from the handler.