Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
node http request leak FIX!
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)
} else {
// POST (or any other)
console.log(req.method + ' request');
weak(req, collectPOST)
req.on('end', function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment