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

Promise.delay will not clearTimeout when cancelled #1000

Closed
yonjah opened this issue Feb 9, 2016 · 0 comments
Closed

Promise.delay will not clearTimeout when cancelled #1000

yonjah opened this issue Feb 9, 2016 · 0 comments

Comments

@yonjah
Copy link
Contributor

yonjah commented Feb 9, 2016

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

yonjah added a commit to yonjah/bluebird that referenced this issue Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants