Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for very nested promises #73

Open
ForbesLindesay opened this issue Apr 3, 2015 · 1 comment
Open

Add test case for very nested promises #73

ForbesLindesay opened this issue Apr 3, 2015 · 1 comment

Comments

@ForbesLindesay
Copy link
Member

When attempting to fix a memory leak caused by nested promises I inadvertently completely broke my library once more than a couple of promises were nested (see then/promise#67). I caught it with the following test:

    var promises = [];
    var resolveFns = [];
    for (var i = 0; i < 100; i++) {
      promises.push(new Promise(function (resolve) {
        resolveFns.push(resolve);
      }));
    }
    for (var i = 0; i < 99; i++) {
      resolveFns[i](promises[i + 1]);
    }
    resolveFns[99]('foo');
    return promises[0].then(function (result) {
      assert(result === 'foo');
    });

It took me a long time to realise that I might have an bug in that place so it would be great if we could add a test like this so that other people don't suffer the same problem.

@domenic
Copy link
Member

domenic commented Apr 3, 2015

For sure, PR welcome. Should be pretty easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants