-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timers: fix handling of cleared immediates
If current immediate has no callback, move on to the next one in the queue. Fixes: #9756 PR-URL: #9759 Reviewed-By: Jeremiah Senkpiel <[email protected]>
- Loading branch information
1 parent
45d1c49
commit 3605726
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that if an Immediate callback clears subsequent | ||
// immediates we don't get stuck in an infinite loop. | ||
// | ||
// If the process does get stuck, it will be timed out by the test | ||
// runner. | ||
// | ||
// Ref: https://github.com/nodejs/node/issues/9756 | ||
|
||
setImmediate(common.mustCall(function() { | ||
clearImmediate(i2); | ||
clearImmediate(i3); | ||
})); | ||
|
||
const i2 = setImmediate(function() { | ||
common.fail('immediate callback should not have fired'); | ||
}); | ||
|
||
const i3 = setImmediate(function() { | ||
common.fail('immediate callback should not have fired'); | ||
}); |