Skip to content

Commit ea16354

Browse files
committed
timers: fix arbitrary object clearImmediate errors
Fix errors that are caused by invoking clearImmediate with arbitrary objects. fixes: #37806
1 parent d3417bb commit ea16354

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/internal/timers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ ImmediateList.prototype.append = function(item) {
279279
// Removes an item from the linked list, adjusting the pointers of adjacent
280280
// items and the linked list's head or tail pointers as necessary
281281
ImmediateList.prototype.remove = function(item) {
282-
if (item._idleNext !== null) {
282+
if (item._idleNext) {
283283
item._idleNext._idlePrev = item._idlePrev;
284284
}
285285

286-
if (item._idlePrev !== null) {
286+
if (item._idlePrev) {
287287
item._idlePrev._idleNext = item._idleNext;
288288
}
289289

lib/timers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function clearImmediate(immediate) {
283283
toggleImmediateRef(false);
284284
immediate[kRefed] = null;
285285

286-
if (destroyHooksExist()) {
286+
if (destroyHooksExist() && item[async_id_symbol] !== undefined) {
287287
emitDestroy(immediate[async_id_symbol]);
288288
}
289289

0 commit comments

Comments
 (0)