files.watchDir() method in JavaScript and files.watch_dir() method in Python.
Since events are tracked asynchronously, their delivery may be delayed.
It’s recommended not to collect or close watcher immediately after making a change.
Recursive watching
You can enable recursive watching using the parameterrecursive.
When rapidly creating new folders (e.g., deeply nested path of folders), events other than
CREATE might not be emitted. To avoid this behavior, create the required folder structure in advance.Including entry information
You can include information about the affected file or directory in each event using the parameterincludeEntry in JavaScript and include_entry in Python.
When enabled, each event carries the entry’s information — such as its path, type, and size — in the entry field.
Entry information may be unset for remove events since the path no longer exists.
Including entry information requires templates with envd version
v0.6.3 or above — using the includeEntry / include_entry option on older sandboxes will throw an error.Watching network filesystem mounts
By default, watching paths on network filesystem mounts (NFS, CIFS, SMB, FUSE) is rejected. You can explicitly opt in using the parameterallowNetworkMounts in JavaScript and allow_network_mounts in Python.
Events on network mounts may be unreliable or not delivered at all, which is why the explicit opt-in is required.Changes made by another client outside of the sandbox (for example, a different machine writing to the same network share) are not propagated to the watcher — only changes made from within the sandbox are detected.
Watching network mounts requires templates with envd version
v0.6.4 or above — using the allowNetworkMounts / allow_network_mounts option on older sandboxes will throw an error.