Timers
clearInterval()
Stops future interval callbacks for a timer handle. In-flight asynchronous work is not canceled by this operation. Use separate cancellation for that work and clear the interval in cleanup. Tested on Node.js 22.16.0. Example output (one line per entry): ["0"].
Formal Syntax & Structure
nodejs syntaxnodejs
clearInterval(timeout)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| timeout | Timeout | string | number | Interval handle or compatible identifier. |
Return Value
undefined
No return value.
Working Example
Example Snippetnodejs
import { setTimeout as wait } from 'node:timers/promises';let calls = 0;const h = setInterval(() => calls++, 1);clearInterval(h);await wait(5);console.log(calls);