# node:timers

> How Elide supports Node's `timers` and `timers/promises` modules: they match Node, including scheduler; `active()` and `unenroll()` are not exposed.

`node:timers` and `node:timers/promises` match [Node's `timers`](https://nodejs.org/api/timers.html), including
`scheduler` and `AbortSignal` support; ordering is covered under [Timers](https://elide.help/docs/api-html-timers).

## Example

```js
// timers.mjs
import { setInterval, setTimeout as sleep } from "node:timers/promises";

console.log(await sleep(10, "woke"));

let ticks = 0;
for await (const _ of setInterval(5)) {
  if (++ticks === 3) break;
}
console.log("ticks", ticks);

const controller = new AbortController();
const pending = sleep(60_000, null, { signal: controller.signal });
controller.abort();
await pending.catch((error) => console.log(error.name));
```

`elide run timers.mjs` prints:

```text
woke
ticks 3
AbortError
```

## Differences from Node

- `node:timers` functions are not the same objects as the timer globals.
- `active()` and `unenroll()` are not exposed.

<!-- api-reference:start 6e1b45e455f6 -->
## Reference

**Status:** Full · 54 of 57 suite tests pass (94.7%) · since 1.1.0

### Exports

| Export | Kind | Status | Notes |
| --- | --- | --- | --- |
| `setTimeout()` | function | Full | Schedules a callback to be invoked once after `delay` milliseconds |
| `clearTimeout()` | function | Full | Cancels a timeout previously established by setTimeout() |
| `setInterval()` | function | Full | Schedules a callback to be invoked repeatedly every `delay` milliseconds |
| `clearInterval()` | function | Full | Cancels an interval previously established by setInterval() |
| `setImmediate()` | function | Full | Schedules a callback to be invoked asynchronously "immediately" (after I/O events but before timers… |
| `clearImmediate()` | function | Full | Cancels an immediate action previously established by setImmediate() |

**Tests:** [node-api `node:timers`](https://github.com/elide-dev/testsuite/blob/main/reports/1.6.0%2B6e718933f/4cbcae6c33a8/node-api/node-api.md): 54 pass, 3 fail, 0 error, 10 skipped. Failing: `test-timers-max-duration-warning.js`, `test-timers-timeout-to-interval.js`, `test-timers-unenroll-unref-interval.js`.
<!-- api-reference:end -->
