Created
August 10, 2020 21:55
-
-
Save mmarchini/0c77b6756bee23e27a0eb46e9dd85f5e to your computer and use it in GitHub Desktop.
resource-leak.js
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
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'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment