You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: File watcher stops triggering after first save in VS Code and other IDEs #432
Description: While testing the microcks import --watch command, I noticed that file changes are only detected on the first save when editing specs in editors like VS Code or IntelliJ. After the initial save, subsequent saves are ignored and the watcher no longer triggers imports.
Expected Behavior : The watcher should continue monitoring the file and trigger imports on every save.
Actual behavior : The watch appears to be lost after the first save, so later modifications are ignored silently.
Possible cause: It looks related to how some editors perform atomic saves by writing to a temporary file and renaming it over the original file. In that case, fsnotify emits Rename/Remove events instead of only Write, and the existing watch may get dropped without being re-registered.
Reproduced on master (f9550f5) against a real Microcks server, using microcks import <file>:true --watch and comparing in-place writes with atomic saves (write a temp file, then mv it over the original).
Platform
Atomic save
Later in-place edits
Linux (inotify, alpine container)
0 re-imports
0 re-imports, the watcher is dead
macOS (kqueue)
0 re-imports, so the saved edit is lost
still trigger (1 each)
In-place writes (the control) trigger a re-import on both platforms (1 on macOS, 2 on Linux, see #297).
Cause: RunContext in pkg/watcher/watchManager.go only handles fsnotify.Write events. A rename-over (what atomic saves do) emits Rename/Remove/Create, which are ignored, and the watch on the replaced inode is never re-added.
Suggested fix: also handle Create, Rename and Remove events, and re-add the watch (or watch the parent directory and filter by name). This shares a code area with #297, so one PR could cover both.
Update: PR #586 ("File watcher stops triggering after first save") looks like it addresses this. I built its head and ran import --watch against a real server on macOS, compared with master:
Plain write, atomic save (temp file plus mv), write after the atomic save, second atomic save: 4 re-imports with the PR, versus 2 on master (both atomic saves lost).
A burst of 20 appends: 1 re-import with the PR, versus 12 on master.
Not tested: Linux (inotify), where the watcher died after an atomic save on master. That should be checked before merging.
Disclosure: this comment was drafted with AI assistance, and the results were run locally.
Activity
yada commentedon Oct 14, 2026
Reproduced on master (f9550f5) against a real Microcks server, using
microcks import <file>:true --watchand comparing in-place writes with atomic saves (write a temp file, thenmvit over the original).In-place writes (the control) trigger a re-import on both platforms (1 on macOS, 2 on Linux, see #297).
Cause:
RunContextinpkg/watcher/watchManager.goonly handlesfsnotify.Writeevents. A rename-over (what atomic saves do) emitsRename/Remove/Create, which are ignored, and the watch on the replaced inode is never re-added.Suggested fix: also handle
Create,RenameandRemoveevents, and re-add the watch (or watch the parent directory and filter by name). This shares a code area with #297, so one PR could cover both.yada commentedon Oct 17, 2026
Update: PR #586 ("File watcher stops triggering after first save") looks like it addresses this. I built its head and ran
import --watchagainst a real server on macOS, compared with master:mv), write after the atomic save, second atomic save: 4 re-imports with the PR, versus 2 on master (both atomic saves lost).Not tested: Linux (inotify), where the watcher died after an atomic save on master. That should be checked before merging.
Disclosure: this comment was drafted with AI assistance, and the results were run locally.