watcher.js adjustments#21
Merged
commenthol merged 3 commits intocommenthol:masterfrom Jan 2, 2025
Merged
Conversation
Owner
|
@H4wk507 Thanks for your fixes. A new version md-fileserver@1.10.2 is published. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @commenthol, thanks for this amazing project.
This PR fixes a memory leak in
watcher.js. The leak can be reproduced by runningnode --trace-gc bin/mdstart.js file.mdand repeatedly saving the file. The number of file watchers grows rapidly and files are not being unwatched properly. This is related to #8. I've added awatchedFilesset to track currently watched files, ensuring no file is watched more than once. I've also implemented better cleanup and connection close handling.Also, I've added the 100ms debounce in the
onChangefunction to prevent race conditions between WebSocket broadcasts and file system events. This prevents "Document not found" errors mentioned here #7.There is also a small change in
template.html. I've removed the Google's 'translate the page' popup that was showing after each file save. I've found it to be annoying.