mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
timers: check for immediate instance in clearImmediate
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
d1ec948866
commit
6b0af1748c
|
|
@ -301,7 +301,7 @@ ObjectDefineProperty(setImmediate, customPromisify, {
|
|||
* @returns {void}
|
||||
*/
|
||||
function clearImmediate(immediate) {
|
||||
if (!immediate || immediate._destroyed)
|
||||
if (!immediate?._onImmediate || immediate._destroyed)
|
||||
return;
|
||||
|
||||
immediateInfo[kCount]--;
|
||||
|
|
|
|||
13
test/parallel/test-timers-invalid-clear.js
Normal file
13
test/parallel/test-timers-invalid-clear.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
// clearImmediate should be a noop if anything other than an Immediate
|
||||
// is passed to it.
|
||||
|
||||
const t = setTimeout(common.mustCall());
|
||||
|
||||
clearImmediate(t);
|
||||
|
||||
setTimeout(common.mustCall());
|
||||
setTimeout(common.mustCall());
|
||||
Loading…
Reference in New Issue
Block a user