Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): add Timeout class #1699

Merged
merged 10 commits into from
Jan 19, 2022
Merged

feat(node): add Timeout class #1699

merged 10 commits into from
Jan 19, 2022

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Dec 10, 2021

closes #1622

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

I'm against merging this before tomorrow's meeting

@bnoordhuis
Copy link
Contributor

@bartlomieju Can you outline your objections?

@bartlomieju
Copy link
Member

@bnoordhuis importing node/global.ts will implicitly override existing timers APIs available in Deno. IIRC we tentatively agreed that we will change return types of global APIs instead of overriding them only in node/global.ts. so I'd prefer to discuss it once more before landing.

@bartlomieju
Copy link
Member

Okay, so we discussed this PR during the design meeting.

The consensus was that we shouldn't mess with global types - we should keep Web compatible types and we shouldn't override setTimeout and setInterval when importing deno_std/node or running in compat mode. What we want to do is return "timer object" when you import these APIs like: require("timers").setTimeout.

We searched using SourceGraph for packages using ref()/unref() for timers and we found there are about 500 of them. Most of them are rather popular packages (like webpack, socket.io, mocha) and we feel we should open PRs in these repos that change the usage from using global setTimeout/setInterval to one imported from "timers" module.

@kt3k kt3k force-pushed the feat/node-timeout branch from a968f0b to e6960e9 Compare December 22, 2021 06:47
@kt3k
Copy link
Member Author

kt3k commented Dec 22, 2021

I reverted exposing global part of this PR for now.

Most of them are rather popular packages (like webpack, socket.io, mocha) and we feel we should open PRs in these repos that change the usage from using global setTimeout/setInterval to one imported from "timers" module.

I feel that might be very difficult because they have small motivation to accept such PRs (in case of mocha, they probably even don't have time to start reviewing it. They seem very inactive.), but let's see how it works for a while.

@bnoordhuis
Copy link
Contributor

Seconded. I think you're being way too optimistic on the probability of such PRs getting accepted and merged/released in a timely fashion. To maintainers of those packages it's all downside and little or no upside.

We're aiming for end of January for v0. Being blocked on third parties is not an option.

@kt3k
Copy link
Member Author

kt3k commented Jan 18, 2022

Merged main.

This PR now doesn't include replace globals part. This only provides timers module with compatible APIs. So I think this PR is now landable. @bartlomieju

Comment on lines 1 to 2
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this file was accidentally resurrected during a rebase?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, thanks! This was a mistake during resolving merge conflicts!

@kt3k
Copy link
Member Author

kt3k commented Jan 19, 2022

Merging this as it doesn't include the controversial part of timers compatibility issue.

I'm going to try to implement the idea of providing node-compatible timers via commonJS wrapper function

@kt3k kt3k merged commit 7e2e6b9 into denoland:main Jan 19, 2022
@kt3k kt3k deleted the feat/node-timeout branch January 19, 2022 05:00
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.

std/node: Node compatible setTimeout, setInterval
3 participants