Skip to content

Instantly share code, notes, and snippets.

@rnchamberlain
Created September 14, 2017 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnchamberlain/563d575f129867bd23c3c7da001d888b to your computer and use it in GitHub Desktop.
Save rnchamberlain/563d575f129867bd23c3c7da001d888b to your computer and use it in GitHub Desktop.
Simple testcase for rejected promise
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