sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[CP] "Directory watcher closed unexpectedly" on Windows during Flutter builds

Open DanTup opened this issue 3 years ago • 3 comments

Commit(s) to merge

019cfb9

Target

beta

Issue Description

For Flutter users on Windows, running the application will sometimes trigger an exception on the analysis server ("Socket error: FileSystemException: Directory watcher closed unexpectedly") because the volume of file modifications overflows the watchers buffer but the server does not correctly handle the error.

What is the fix

An error handler should be attached to the watchers that restarts the context rebuild of this condition occurs, to ensure the server re-reads the state from disk and has a consistent view of the files on disk.

Why cherry-pick

This issue has been reported by a number of Windows users on GitHub and discord.

  • https://github.com/dart-lang/sdk/issues/49286
  • https://github.com/Dart-Code/Dart-Code/issues/4077
  • https://discord.com/channels/615553440969392147/615553440969392151/1003592220059901962

While I'm not sure how many users are really affected, it could be easy to overlook the error message and keep working with an inconsistent server (which could result in hard to track down issues, or invalid edits being produced mess up users code). It's likely that larger projects (or those that modify more files in the build folder) are more likely to trigger this, although there may be other factors (such as machine or disk performance).

Risk

low

Issue link(s)

https://github.com/dart-lang/sdk/issues/49286

Extra Info

I verified that this change merges cleanly into the current beta (395f6163303).

DanTup avatar Aug 01 '22 15:08 DanTup

@athomas @johnniwinther @vsmenon @a-siva thoughts on this cherry-pick request?

itsjustkevin avatar Aug 01 '22 15:08 itsjustkevin

lgtm.

a-siva avatar Aug 02 '22 17:08 a-siva

lgtm

athomas avatar Aug 09 '22 13:08 athomas

lgtm

vsmenon avatar Aug 11 '22 22:08 vsmenon

This commit has been cherry-picked in 2.18.0-271.7.beta (0283de5506a5bd7d0e63e2092bf53ec93adddbd1).

sortie avatar Aug 15 '22 11:08 sortie