{"action":"closed","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/963","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/963/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/963/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/963/events","html_url":"https://github.com/petkaantonov/bluebird/issues/963","id":126969041,"number":963,"title":"finally not called on cancel when Node.js domain is active (i.e. process.domain !== undefined)","user":{"login":"heskew","id":132403,"avatar_url":"https://avatars.githubusercontent.com/u/132403?v=3","gravatar_id":"","url":"https://api.github.com/users/heskew","html_url":"https://github.com/heskew","followers_url":"https://api.github.com/users/heskew/followers","following_url":"https://api.github.com/users/heskew/following{/other_user}","gists_url":"https://api.github.com/users/heskew/gists{/gist_id}","starred_url":"https://api.github.com/users/heskew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heskew/subscriptions","organizations_url":"https://api.github.com/users/heskew/orgs","repos_url":"https://api.github.com/users/heskew/repos","events_url":"https://api.github.com/users/heskew/events{/privacy}","received_events_url":"https://api.github.com/users/heskew/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/petkaantonov/bluebird/labels/3.0.0","name":"3.0.0","color":"5319e7"},{"url":"https://api.github.com/repos/petkaantonov/bluebird/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-15T22:12:20Z","updated_at":"2016-01-23T22:18:56Z","closed_at":"2016-01-23T22:18:56Z","body":"The wrapped handler fails the `handler === finallyHandler` check in `Promise.prototype._settlePromise`.\r\n\r\nTo repro, add this test case to the cancel.js test:\r\n\r\n```\r\n    if (testUtils.isNodeJS) {\r\n        specify(\"cancels the promise chain within a domain\", function() {\r\n            var called = false;\r\n            var thens = 0;\r\n            var resolveChain;\r\n\r\n            require(\"domain\").create().enter();\r\n\r\n            var root = new Promise(function(resolve, reject, onCancel) {\r\n                resolveChain = resolve;\r\n                onCancel(function() {\r\n                    called = true;\r\n                });\r\n            }).then(function() {\r\n                thens++;\r\n            }).then(function() {\r\n                thens++;\r\n            }).then(function() {\r\n                thens++;\r\n            });\r\n\r\n            root.cancel();\r\n            resolveChain();\r\n            return awaitLateQueue(function() {\r\n                assert.equal(0, thens);\r\n                assert(called);\r\n            });\r\n        });\r\n    }\r\n```"}}