Skip to content

Instantly share code, notes, and snippets.

@victorquinn victorquinn/.gitignore
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.