Skip to content

finally not called on cancel when Node.js domain is active (i.e. process.domain !== undefined) #963

Description

@heskew

The wrapped handler fails the handler === finallyHandler check in Promise.prototype._settlePromise.

To repro, add this test case to the cancel.js test:

    if (testUtils.isNodeJS) {
        specify("cancels the promise chain within a domain", function() {
            var called = false;
            var thens = 0;
            var resolveChain;

            require("domain").create().enter();

            var root = new Promise(function(resolve, reject, onCancel) {
                resolveChain = resolve;
                onCancel(function() {
                    called = true;
                });
            }).then(function() {
                thens++;
            }).then(function() {
                thens++;
            }).then(function() {
                thens++;
            });

            root.cancel();
            resolveChain();
            return awaitLateQueue(function() {
                assert.equal(0, thens);
                assert(called);
            });
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions