Skip to content

Instantly share code, notes, and snippets.

@mmarchini
Created August 10, 2020 21:55
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 mmarchini/0c77b6756bee23e27a0eb46e9dd85f5e to your computer and use it in GitHub Desktop.
Save mmarchini/0c77b6756bee23e27a0eb46e9dd85f5e to your computer and use it in GitHub Desktop.
resource-leak.js
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