Skip to content

Conversation

@AyushAnand-28
Copy link

Refs: #60859

Description

This PR improves the fs.watch documentation by adding a new section explaining the behavior of file watching during rapid file operations.

Changes

Added a new "Event Reliability with Rapid Operations" section to the fs.watch caveats that:

  • Explains that rapid file create/modify/delete operations may cause missed or coalesced events
  • Clarifies this is due to underlying OS file watching mechanisms (inotify, FSEvents, ReadDirectoryChangesW)
  • Provides recommendations for applications requiring reliable event detection:
    • Use third-party libraries like chokidar
    • Use fs.watchFile() for critical individual files
    • Implement debouncing logic in event handlers

Motivation

Issue #60859 reported that fs.watch misses events during rapid file operations. This is expected behavior due to OS-level limitations, not a Node.js bug. This documentation improvement helps users understand this limitation and provides alternative solutions.

Refs: nodejs#60859

Add a new section to the fs.watch documentation explaining that rapid file operations may cause missed or coalesced events due to underlying OS file watching mechanisms. Provide recommendations for applications requiring reliable event detection, including using third-party libraries like chokidar, fs.watchFile for critical files, or implementing debouncing logic.
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants