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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/timers/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ pub fn op_global_timer_start(
timeout: u64,
_: (),
) -> Result<(), AnyError> {
// According to spec, minimum allowed timeout is 4 ms.
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
// TODO(#10974) Per spec this is actually a little more complicated than this.
// The minimum timeout depends on the nesting level of the timeout.
let timeout = std::cmp::max(timeout, 4);

let deadline = Instant::now() + Duration::from_millis(timeout);
let global_timer = state.borrow_mut::<GlobalTimer>();
global_timer.new_timeout(deadline);
Expand Down