Skip to content

Commit 6101d52

Browse files
committed
move cache assignment to toPrimitive call
1 parent 9ac2bd4 commit 6101d52

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/timers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ const KNOWN_TIMERS = Object.create(null);
151151
// Schedule or re-schedule a timer.
152152
// The item must have been enroll()'d first.
153153
const active = exports.active = function(item) {
154-
KNOWN_TIMERS[item[async_id_symbol]] = item;
155154
insert(item, false);
156155
};
157156

@@ -537,7 +536,9 @@ function unrefdHandle(timer, now) {
537536
}
538537

539538
Timeout.prototype[Symbol.toPrimitive] = function() {
540-
return this[async_id_symbol];
539+
const id = this[async_id_symbol];
540+
KNOWN_TIMERS[id] = this;
541+
return id;
541542
};
542543

543544
Timeout.prototype.unref = function() {

0 commit comments

Comments
 (0)