Timers

clearTimeout()

Cancels a scheduled timeout that has not fired. It cannot undo work already started by its callback. Keep the handle at the owner boundary and cancel when an operation is no longer needed. Tested on Node.js 22.16.0. Example output (one line per entry): ["false"].

Formal Syntax & Structure

nodejs syntaxnodejs
clearTimeout(timeout)

Parameters & Attributes

NameTypeDescription
timeoutTimeout | string | numberTimeout handle or compatible identifier.

Return Value

undefined

No return value.

Working Example

Example Snippetnodejs
import { setTimeout as wait } from 'node:timers/promises';let ran = false;const t = setTimeout(() => { ran = true; }, 1);clearTimeout(t);await wait(5);console.log(ran);
Node.js Reference