Skip to content

watcher.js adjustments#21

Merged
commenthol merged 3 commits intocommenthol:masterfrom
H4wk507:watcher-adjustments
Jan 2, 2025
Merged

watcher.js adjustments#21
commenthol merged 3 commits intocommenthol:masterfrom
H4wk507:watcher-adjustments

Conversation

@H4wk507
Copy link
Copy Markdown
Contributor

@H4wk507 H4wk507 commented Dec 13, 2024

Hi @commenthol, thanks for this amazing project.
This PR fixes a memory leak in watcher.js. The leak can be reproduced by running node --trace-gc bin/mdstart.js file.md and 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 a watchedFiles set 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 onChange function 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.

@commenthol commenthol merged commit e0b5bd1 into commenthol:master Jan 2, 2025
@commenthol
Copy link
Copy Markdown
Owner

@H4wk507 Thanks for your fixes. A new version md-fileserver@1.10.2 is published.

@commenthol commenthol mentioned this pull request Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants