make-promises-safe
Version:
Crash or abort if you get an unhandledRejection or multipleResolves
23 lines (17 loc) • 374 B
JavaScript
// require('.').abort = true;
const http = require('http')
const server = http.createServer(handle)
server.listen(3000)
function handle (req, res) {
doStuff()
.then((body) => {
res.end(body)
})
}
function doStuff () {
if (Math.random() < 0.5) {
return Promise.reject(new Error('kaboom'))
}
return Promise.resolve('hello world')
}