Skip to content

Commit 736537f

Browse files
gurgundayRafaelGSS
authored andcommitted
timers: check for immediate instance in clearImmediate
PR-URL: #57069 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 1b3cf85 commit 736537f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/timers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ObjectDefineProperty(setImmediate, customPromisify, {
301301
* @returns {void}
302302
*/
303303
function clearImmediate(immediate) {
304-
if (!immediate || immediate._destroyed)
304+
if (!immediate?._onImmediate || immediate._destroyed)
305305
return;
306306

307307
immediateInfo[kCount]--;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
// clearImmediate should be a noop if anything other than an Immediate
6+
// is passed to it.
7+
8+
const t = setTimeout(common.mustCall());
9+
10+
clearImmediate(t);
11+
12+
setTimeout(common.mustCall());
13+
setTimeout(common.mustCall());

0 commit comments

Comments
 (0)