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 subsequent enroll calls not working
A bug was introduced in nodejs#17704 which meant that subsequent calls to enroll would unset the new _idleTimeout and the enrolled object could never again function as a timer.
- Loading branch information
1 parent
fa2d43b
commit e838531
Showing
2 changed files
with
18 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,16 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const assert = require('assert'); | ||
const timers = require('timers'); | ||
|
||
let didCall = false; | ||
const enrollObj = { | ||
_onTimeout: common.mustCall(() => assert(didCall)), | ||
}; | ||
|
||
timers.enroll(enrollObj, 1); | ||
timers.enroll(enrollObj, 10); | ||
timers.active(enrollObj); | ||
setTimeout(common.mustCall(() => { didCall = true; }), 1); |