forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timers: fix regression with clearImmediate()
This commit fixes a regression introduced in 0ed8839 that caused additional queued immediate callbacks to be ignored if `clearImmediate(immediate)` was called within the callback for `immediate`. Fixes: nodejs#9084
- Loading branch information
Showing
2 changed files
with
28 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,18 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
const N = 3; | ||
var count = 0; | ||
function next() { | ||
const immediate = setImmediate(function() { | ||
clearImmediate(immediate); | ||
++count; | ||
}); | ||
} | ||
for (var i = 0; i < N; ++i) | ||
next(); | ||
|
||
process.on('exit', () => { | ||
assert.strictEqual(count, N, `Expected ${N} immediate callback executions`); | ||
}); |