Skip to content

Add test case for very nested promises #73

@ForbesLindesay

Description

@ForbesLindesay

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions