Skip to content

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

Closed

Description

@pierre-cheneau

Steps to reproduce

Windows 10, Flutter 3.44.9 stable (also reproducible with any recent stable).

  1. flutter create mini && cd mini && flutter run -d windows
  2. Edit lib/main.dart, hot reload → applied (compile "1 updated files").
  3. Within the same wall-clock second as that compile, edit lib/main.dart again
    (an IDE/agent/script saving right after the reload finishes; the reload itself
    takes ~300 ms) and press r (or R) again.

Expected results

The second edit is compiled and reloaded/restarted.

Actual results

flutter run -v shows Compiling dart to kernel with 0 updated files; the app keeps
running the previous source. Waiting until the next second before saving makes it work.

Cause

ProjectFileInvalidator.findInvalidated compares statSync().modified.isAfter(lastCompiled)
(packages/flutter_tools/lib/src/run_hot.dart), where lastCompiled is a millisecond
DateTime.now() captured at the start of DevFS.update. On Windows dart:io reports
file mtimes truncated to whole seconds:

final f = File('x')..writeAsStringSync('a');
print(DateTime.now());            // 09:52:37.637611
print(f.statSync().modified);     // 09:52:37.000  ← truncated

So an edit at 09:52:37.637 after a compile that started at 09:52:37.271 has mtime
09:52:37.000, which is not isAfter(lastCompiled), and is dropped. Consecutive human
r presses rarely fall in the same second, but IDE "reload on save" and agent
tooling (edit → reload immediately) hit it constantly, and the failure is silent.

Suggested fix

Truncate lastCompiled to second precision on Windows before comparing (or compare
!updatedAt.isBefore(lastCompiledTruncatedToSecond)), or use a strictly monotone
per-file mtime snapshot instead of a wall-clock cut-off. Alternatively fix
FileStat.modified precision in dart:io on Windows (uses _wstat64 → time_t).

Logs

[        ] Performing hot restart...
[  +85 ms] Scanned through 677 files in 85ms
[        ] Compiling dart to kernel with 0 updated files
[        ] Restarted application in 349ms.

Flutter Doctor output

flutter doctor -v
[√] Flutter (Channel stable, 3.44.9, on Microsoft Windows [version 10.0.19045.6466], locale fr-FR) [545ms]
    • Flutter version 3.44.9 on channel stable at C:\dev\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • FLUTTER_GIT_URL = https://github.com/flutter/flutter.git
    • Framework revision 6b182d2c75 (12 days ago), 2026-08-05 10:04:07 -0700
    • Engine revision 5a2a6a42cc
    • Dart version 3.12.2
    • DevTools version 2.57.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[√] Windows Version (10 Famille 64 bits, 22H2, 2009) [3,6s]
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3,9s]
    • Android SDK at C:\Users\corne\AppData\Local\Android\sdk
    • Emulator version 32.1.15.0 (build_id 10696886) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    • All Android licenses accepted.
[√] Chrome - develop for the web [176ms]
    • CHROME_EXECUTABLE = C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe
[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.14.25 (January 2026)) [175ms]
    • Visual Studio at Z:\Microsoft Visual Studio\2022\Professional
    • Visual Studio Professional 2022 version 17.14.36915.13
    • Windows 10 SDK version 10.0.26100.0
[√] Connected device (3 available) [355ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [version 10.0.19045.6466]
    • Chrome (web)      • chrome  • web-javascript • unknown
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 150.0.4078.105
[√] Network resources [410ms]
    • All expected network resources are available.
• No issues found!

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-windowsBuilding on or for Windows specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-toolOwned by Flutter Tool team
    on Aug 17, 2026
  2. mbcorona commented on Aug 17, 2026

    @mbcorona
    Member

    Hi @pierre-cheneau, thanks for the report and the clear root-cause analysis. Confirmed in run_hot.dart — routing to the tool team.

  3. added
    triaged-toolTriaged by Flutter Tool team
    P2Important issues not at the top of the work list
    on Aug 18, 2026
  4. self-assigned this
    on Aug 18, 2026
  5. github-actions commented on Sep 2, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-windowsBuilding on or for Windows specificallyteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions