Skip to content

fix(clock): fast-forward by more than 2^31 ms - #43784

Open
Victor Hugo Macedo Paes Leme (zerotohero3) wants to merge 1 commit into
microsoft:mainfrom
zerotohero3:fix-43783
Open

Victor Hugo Macedo Paes Leme (zerotohero3) wants to merge 1 commit into
microsoft:mainfrom
zerotohero3:fix-43783

Conversation

@zerotohero3

Copy link
Copy Markdown

Summary

  • fastForward() truncated ticks with | 0, so anything over 2^31 - 1 ms (~24.8 days) wrapped around: 25 days threw "Cannot fast-forward to the past", 50 days only moved ~7h. Use Math.trunc() instead, same result for smaller values.
  • | 0 was also what turned NaN/Infinity into a no-op on the current page (they still broke Date after a reload, since the init-script log keeps the raw value), and without it fastForward(Infinity) spins forever on any interval. Reject non-finite ticks in parseTicks(), like parseTime() already does for invalid dates. That covers runFor(NaN) too, which used to leave Date.now() as NaN.

Fixes #43783

@zerotohero3

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
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.

[Bug]: clock.fastForward() over ~24.8 days throws or jumps to the wrong time

1 participant