-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Using bluebird 3.2.2
Similar to #926 with timeout When canceling a Promise.delay the internally used timeout is not cleared and the process will hang
var Promise = require('bluebird');
Promise.config({cancellation: true});
process.on('exit', function() {
console.log(new Date(), 'Process exiting');
});
console.log(new Date(), 'Starting');
var delayPromise = Promise.delay(10000);
delayPromise.finally(function () {
if (delayPromise.isCancelled()) {
console.log(new Date(), 'Cancelled');
}
});
setTimeout(function() {
console.log(new Date(), 'Cancelling promise');
delayPromise.cancel();
}, 1000);Output -
Tue Feb 09 2016 05:17:03 GMT+0000 (UTC) 'Starting'
Tue Feb 09 2016 05:17:04 GMT+0000 (UTC) 'Canceling promise'
Tue Feb 09 2016 05:17:04 GMT+0000 (UTC) 'Cancelled'
Tue Feb 09 2016 05:17:13 GMT+0000 (UTC) 'Process exiting'
Notice the 10 seconds delay between the promise being canceled and the process exiting
Reactions are currently unavailable