Created
September 14, 2017 09:45
-
-
Save rnchamberlain/563d575f129867bd23c3c7da001d888b to your computer and use it in GitHub Desktop.
Simple testcase for rejected promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var count = 0; | |
function doit() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => reject('FAILED'), 100); | |
}); | |
} | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
doit() | |
.then(console.log); | |
//.catch(function(error) { | |
// console.error('An error occurred', error); | |
//}); | |
res.end('Test promise unhandled rejection\n'); | |
}).listen(8080); | |
console.log('loop.js: Node running, go to http://<machine>:8080/ or http://localhost:8080/ now'); | |
console.log('pid ' + process.pid); | |
setInterval(function(){ | |
console.log('tick'); | |
}, 10000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment