Skip to content

Conversation

@sapphi-red
Copy link
Member

Description

I encountered a flaky failure related to these tests and once thought the cause is #19804. But it turned out, it wasn't 😅.
Anyway, it would be good to fix this issue, so I made this PR.

This PR changes Date.now() to monotinicDateNow() so that the timestamp is always different for each update.

fixes #19804

@sapphi-red sapphi-red added feat: hmr p3-minor-bug An edge case that only affects very specific usage (priority) labels Jun 5, 2025
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Sometime ago I've attempted fixing this by using higher precision but it was somehow tricky to deal with fractional value as timestamp and it was breaking. I worried that module graph property like ModuleNode.lastInvalidationTimestamp, lastHMRTimestamp not being an actual Date.now value might break some users assumption, but I think fluctuation of a few milliseconds shouldn't cause issues in practice.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

great fix!

@patak-dev patak-dev merged commit 8d26785 into vitejs:main Jun 5, 2025
17 checks passed
@sapphi-red sapphi-red deleted the fix/hmr-use-monotonic-date-now branch June 6, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: hmr p3-minor-bug An edge case that only affects very specific usage (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformRequest can leave transformResult as null when called right after invalidateModule

3 participants