Skip to content

Instantly share code, notes, and snippets.

@victorquinn
Last active August 29, 2015 13:56
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 victorquinn/9004347 to your computer and use it in GitHub Desktop.
Save victorquinn/9004347 to your computer and use it in GitHub Desktop.
Bluebird memory leak
node_modules
var Promise = require('bluebird'),
express = require('express'),
request = require('request'),
step = require('step');
var app = express();
// test endpoint to test this request
app.post('/test', function(req, res) {
res.json({success: true});
});
var server = app.listen(3000);
function make_request_normal(callback) {
request.post({
url: "http://localhost:3000/test",
method: "POST",
body: JSON.stringify({first_name: "Victor"})
}, function(err, response, body) {
callback(err, response, body);
});
}
function make_request_with_step(callback) {
step(
function() {
// noop
this(null, 'test');
},
function(err, test) {
request.post({
url: "http://localhost:3000/test",
method: "POST",
body: JSON.stringify({first_name: "Victor"})
}, this);
},
function(err, response, body) {
callback(null, response, body);
}
);
}
// Works fine
// make_request(function(err, response) {
// console.log(body);
// server.close();
// });
// Blows up?
// Promise.promisify(make_request_normal)().spread(function(response, body) {
// console.log(response);
// console.log(body);
// server.close();
// });
Promise.promisify(make_request_with_step)().spread(function(response, body) {
console.log(body);
server.close();
});
{
"dependencies": {
"bluebird": "~0.11.5-0",
"request": "~2.33.0",
"express": "~3.4.8",
"step": "0.0.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment