Repository navigation
[tool] Fix Windows hot reload mtime truncation issue - #191271
Merged
Merged
Conversation
`dart:io` on Windows truncates `FileStat.modified` to second precision. This causes `ProjectFileInvalidator.findInvalidated` to miss files modified in the same second as `lastCompiled` because `updatedAt.isAfter(lastCompiled)` fails when `lastCompiled` has millisecond precision and `updatedAt` is truncated. Fix this by truncating `lastCompiled` to second precision on Windows and using `!updatedAt.isBefore(lastCompiledTruncated)` to ensure files modified in the same second are considered invalidated. Fixes flutter#191198
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces platform-specific file invalidation logic for Windows in ProjectFileInvalidator, truncating compilation timestamps to the nearest second to handle differences in file modification time precision. Corresponding tests are added to verify this behavior on Windows and non-Windows platforms. Feedback suggests refactoring the isInvalidated helper function to be conditionally defined based on the platform, which simplifies the logic, removes the nullable variable and bang operator, and avoids redundant platform checks during scanning.
loic-sharma
reviewed
Aug 18, 2026
Co-authored-by: Loïc Sharma <[email protected]>
This was referenced Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
dart:ioreportsFileStat.modifiedtruncated to second precision (viaGetFileAttributesExW). WhenProjectFileInvalidator.findInvalidatedcompares file modification times withlastCompiled(which is recorded with millisecond precision), files edited in the same second as the previous compilation are ignored becauseupdatedAt.isAfter(lastCompiled)returnsfalse.This PR fixes the issue by truncating
lastCompiledto second precision on Windows and using!updatedAt.isBefore(lastCompiledTruncated)to ensure files modified within the same second as the compilation start time are marked as invalidated.Fixes #191198
Pre-launch Checklist
///).