Skip to content

[tool] Fix Windows hot reload mtime truncation issue - #191271

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
bkonyi:issue-191198
Aug 19, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
bkonyi:issue-191198

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

On Windows, dart:io reports FileStat.modified truncated to second precision (via GetFileAttributesExW). When ProjectFileInvalidator.findInvalidated compares file modification times with lastCompiled (which is recorded with millisecond precision), files edited in the same second as the previous compilation are ignored because updatedAt.isAfter(lastCompiled) returns false.

This PR fixes the issue by truncating lastCompiled to 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

bkonyi added 2 commits August 18, 2026 03:28
`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
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 18, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@bkonyi
bkonyi requested a review from loic-sharma August 18, 2026 16:07
loic-sharma
loic-sharma previously approved these changes Aug 18, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with nit

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-LGTM

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 19, 2026
Merged via the queue into flutter:master with commit c6b9816 Aug 19, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2026
@bkonyi bkonyi added the cp: stable cherry pick this pull request to stable release candidate branch label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tool] Hot reload/restart on Windows ignores files edited in the same second as the previous compile (mtime truncated to seconds)

2 participants