Skip to content

feat: use Node.js timers by default#31272

Merged
bartlomieju merged 7 commits intodenoland:mainfrom
bartlomieju:node_timers
Nov 13, 2025
Merged

feat: use Node.js timers by default#31272
bartlomieju merged 7 commits intodenoland:mainfrom
bartlomieju:node_timers

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

This commit changes global setTimeout and setInterval APIs (along their clear* counterparts) to use Node.js APIs instead of the Web APIs.

For real world usage we expect no difference in code and behavior, unless user relies on following checks:

const id = setTimeout(...);
if (typeof id === "number") {
  // ...
}

In which case the conditional should be changed to if (id)

Copilot AI review requested due to automatic review settings November 13, 2025 08:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes a breaking change by replacing the Web API timer implementations with Node.js timer APIs as the default for global setTimeout, setInterval, clearTimeout, and clearInterval functions. The main difference is that Node.js timers return Timeout objects instead of numeric IDs, which could affect code that checks typeof id === "number".

Key Changes

  • Switched from ext:deno_web/02_timers.js to node:timers for global timer functions
  • Removed the unstable nodeGlobals feature flag since Node.js timers are now the default behavior
  • Removed the unused Web API timers import from this file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bartlomieju bartlomieju changed the title feat(BREAKING): use Node.js timers by default feat: use Node.js timers by default Nov 13, 2025
Copy link
Copy Markdown
Contributor

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate, but I think we should do this. Too much server side code relies on this and it works "ok" with most existing web code.

LGTM

@bartlomieju bartlomieju merged commit 7ada8d6 into denoland:main Nov 13, 2025
33 of 36 checks passed
@bartlomieju bartlomieju deleted the node_timers branch November 13, 2025 19:09
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Nov 17, 2025
This commit changes global `setTimeout` and `setInterval` APIs (along
their `clear*` counterparts) to use Node.js APIs instead of the Web
APIs.

For real world usage we expect no difference in code and behavior,
unless user relies on following checks:
```
const id = setTimeout(...);
if (typeof id === "number") {
  // ...
}
```
In which case the conditional should be changed to `if (id)`
@bartlomieju bartlomieju mentioned this pull request Nov 24, 2025
12 tasks
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Dec 3, 2025
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Dec 3, 2025
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Dec 4, 2025
bartlomieju added a commit that referenced this pull request Dec 4, 2025
This reverts commit 7ada8d6.

This is a breaking change and is postponed until Deno 3.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants