Skip to content

Possible memory leak with Promise.each #1057

@tdzienniak

Description

@tdzienniak

I'm using bluebird v3.3.4 running on node v4.4.0. Leaky code:

const Promise = require('bluebird');

Promise.each(new Array(3000), () => {
    const longString = (new Array(1000000)).join('1');

    return Promise.resolve(longString);
});

Not leaky code:

const Promise = require('bluebird');

Promise.each(new Array(3000), () => {
    const longString = (new Array(1000000)).join('1');

    return Promise.resolve(longString).then(() => void 0);
});

It seems that the results of the promises are stored somewhere, but they shouldn't be, at least this is what I understand reading the docs of Promise.each:

Resolves to the original array unmodified, this method is meant to be used for side effects.

Issue is happening on earlier versions of bluebird too.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions