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

set minimum timeout to be 4 milliseconds #10972

Merged
merged 1 commit into from Jun 15, 2021
Merged

set minimum timeout to be 4 milliseconds #10972

merged 1 commit into from Jun 15, 2021

Conversation

ry
Copy link
Member

@ry ry commented Jun 15, 2021

No description provided.

@ry ry requested a review from lucacasonato June 15, 2021 15:36
@lucacasonato
Copy link
Member

Per spec this is actually a little more complicated than this. The minimum timeout depends on the nesting level of the timeout. The actual spec wording is "If nesting level is greater than 5, and timeout is less than 4, then set timeout to 4.". Nesting level increases by 1 every time you call setTimeout or a new timer task is created for setInterval if the parent task of is also a timer task. The nesting level is reset back to 0 if the parent task is not a timer task.

I don't see an easy way to implement this at the moment though, so I'd say good enough for now. We should open an issue to track changing this behaviour to what the spec intends.

@ry
Copy link
Member Author

ry commented Jun 15, 2021

created #10974 and added a TODO comment

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM once test passes.

@piscisaureus
Copy link
Member

I don't see an easy way to implement this at the moment though, so I'd say good enough for now.

I think this is good enough forever.

@lucacasonato
Copy link
Member

I don't see an easy way to implement this at the moment though, so I'd say good enough for now.

I think this is good enough forever.

I don't think so - a single setTimeout(() => {}, 0) is a common way to schedule a piece of code after the microtask queue has cleared. Delaying for 4ms there is not great.

@ry ry merged commit 0c0058f into denoland:main Jun 15, 2021
@ry ry deleted the min-timer branch June 15, 2021 18:18
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.

None yet

3 participants