-
-
Save TooTallNate/2381842 to your computer and use it in GitHub Desktop.
node http request leak FIX!
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') | |
, weak = require('weak') | |
function collectGET() { console.log('GET request collected by GC') } | |
function collectPOST() { console.log('POST request collected by GC') } | |
var server = http.createServer(function(req, res) { | |
if (req.method == 'GET') { | |
// GET | |
console.log('GET request') | |
weak(req, collectGET) | |
res.end() | |
} else { | |
// POST (or any other) | |
console.log(req.method + ' request'); | |
weak(req, collectPOST) | |
req.on('end', function() { | |
res.end() | |
}) | |
} | |
}) | |
server.listen(8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment