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

Cancellation does not clear timeout #926

suprememoocow opened this issue Dec 18, 2015 · 1 comment

Cancellation does not clear timeout #926

suprememoocow opened this issue Dec 18, 2015 · 1 comment


Copy link

@suprememoocow suprememoocow commented Dec 18, 2015

Using bluebird@3.1.1, I've noticed that processes will not shutdown until the timeout has triggered, even if the promise is cancelled.

In this example, I would have expected the process to shutdown after roughly 1s, but the process will take about 10 seconds before shutting down, due to the setTimeout reference called from promise.timeout still being active.

var Promise = require('bluebird');
Promise.config({ cancellation: true });

process.on('exit', function() {
  console.log(new Date(), 'Process exiting');

console.log(new Date(), 'Starting');  
var p = new Promise(function(resolve, reject, onCancel) {
    onCancel(function() {
      console.log(new Date(), 'Cancelled');

// Wait 1s, the
setTimeout(function() {
  console.log(new Date(), 'Cancelling promise');
}, 1000);

The output looks like this

Fri Dec 18 2015 11:22:00 GMT+0000 (GMT) 'Starting'
Fri Dec 18 2015 11:22:01 GMT+0000 (GMT) 'Cancelling promise'
Fri Dec 18 2015 11:22:01 GMT+0000 (GMT) 'Cancelled' 
Fri Dec 18 2015 11:22:10 GMT+0000 (GMT) 'Process exiting'

Notice the 10 second delay on the last log line.

suprememoocow added a commit to gitterHQ/halley that referenced this issue Dec 18, 2015
Copy link

@suprememoocow suprememoocow commented Jan 23, 2016

👍 thank you for this fix and thanks once again for an incredible library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.