dart-lang / watcher

A file system watcher library for Dart.
https://pub.dev/packages/watcher
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

Handle file watcher closed exception #75

Closed MichaelRFairhurst closed 4 years ago

MichaelRFairhurst commented 4 years ago

A better fix for #52 than nothing.

The exception for an unexpectedly closed watcher on windows due to buffer overflow does not get returned on the watcher stream itself. It must be caught with a zone handler: https://github.com/dart-lang/sdk/issues/37233#issuecomment-540659282

This is obviously not ideal. This could be fixed in the SDK itself, however, it is reasonable for package:watcher to handle this quirk like it handles many other. If it gets changed in the SDK this could be dropped when package:watcher depends on that fixed SDK.

In tests, this error handler in package:build does not fire for the unexpectedly closed watcher (https://github.com/dart-lang/build/pull/2505/files#diff-bb055e910a47d24fa146009d257f5946R57) and in the analysis server we are getting these exceptions (https://github.com/dart-lang/sdk/issues/38853) despite a similar handleError call we also have, here: https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/lib/file_system/physical_file_system.dart#L264

MichaelRFairhurst commented 4 years ago

Note: the build seems to have failed for an unrelated reason.

kevmoo commented 4 years ago

Want to update the version to +13 and add a changelog entry?

We can fix the remaining travis issue in a follow-up

MichaelRFairhurst commented 4 years ago

Thanks for review and fixing the build.

I also in further testing noted that actions started in the zone error handler are not run from the zone itself. So I changed it to be recursive.

MichaelRFairhurst commented 4 years ago

Yep, done! (Looks like we just missed each other, timing wise, on that)

MichaelRFairhurst commented 4 years ago

Who is the best person to publish this? I'll be pulling this into the SDK when it's available

natebosch commented 4 years ago

I am doing an internal sync now. If that goes smoothly I will publish and tag.

natebosch commented 4 years ago

This is published and tagged.

MichaelRFairhurst commented 4 years ago

Thanks Nate!