-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re-initialize watchers on rename #67
Conversation
I'm not sure this works as expected. Here's what I just tested:
Another test case (moving files rather than the
I'll defer to your preferences here but my inclination is that |
Here’s what I see. Are you seeing something different? What operating system and version of Node are you running? I am using macOS 14.0 and Node v18.12.1. Screen.Recording.2023-10-26.at.7.14.07.AM.movPutting aside desired actual outcome for a moment, I don’t see any conceptual reason to force a client reload here: there’s no state on the client that is incorrect that needs to be reloaded (nothing that can’t be addressed with a normal incremental update). The only issue with a file being renamed is that the server ends up watching the wrong (moved) file, and we need the server to watch the file in the original place. The practical impact of forcing a client reload should just be to introduce a small and unpredictable delay. If we think we need a small delay, we could do that on the server, too. (Though re-initializing the watcher is already a little slow because we haven’t optimized that path.) Furthermore, forcing a client reload is a bad experience because it discards ephemeral client-side state: potentially expensive operations such as fetching data from remote servers and querying databases need to be re-run, interactive inputs are reset to their default state, and the page scrolls to the top. We want to avoid that as much as possible for a good user experience. Edit: Looking more closely at my video, something appears to be triggering a client reload in this branch? I’ll investigate further as I’m not sure what’s happening. |
Re. |
I'm still on Monterey (12.5.1) but also running Node 18.12.1. Here's what I see: rename-event.mov |
I’ve spotted the problem here (at least in part — there may be some other issue with file watchers macOS 12 that I won’t know how to fix). By calling I’ll also merge the fixes for #63 recently landed in main. |
8a23ea4
to
9215dd6
Compare
Okay, I appear to have got it working correctly now (at least on macOS 14). Screen.Recording.2023-10-26.at.9.02.42.AM.movThe latest commits make the following changes:
|
Please take another look @prichey @wiltsecarpenter? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Works in all the cases I tested
Ref. #64 (review)