Timers

clearImmediate()

Cancels an immediate callback before it executes. This is different from canceling a Promise reaction or a callback already running. Store the returned handle rather than trying to cancel by callback identity. Tested on Node.js 22.16.0. Example output (one line per entry): ["false"].

Formal Syntax & Structure

nodejs syntaxnodejs
clearImmediate(immediate)

Parameters & Attributes

NameTypeDescription
immediateImmediateHandle from setImmediate.

Return Value

undefined

No return value.

Working Example

Example Snippetnodejs
import { setImmediate as turn } from 'node:timers/promises';let ran = false;const h = setImmediate(() => { ran = true; });clearImmediate(h);await turn();console.log(ran);
Node.js Reference