fix(watcher): degrade to slow probes after repeated native watcher failures - #48
Merged
Conversation
…ilures The native session watcher supervisor retried every 30 seconds forever when the child could not stay up. Under inotify watch exhaustion (ENOSPC) that produced 1752 consecutive silent failures over 14.5 hours, with discovery updates degraded the whole time and nothing actionable in the log (#42). - After 20 consecutive failures the restart schedule degrades from the fast exponential backoff to a 10-minute probe cadence: recovery stays automatic when the host condition clears, without a permanent 30s crash loop. - Crossing the cap logs one loud line naming the run length, and when the child's stderr contained the ENOSPC token, the exact remedy (fs.inotify.max_user_watches). Only that fixed token is retained; stderr content itself is still never forwarded, preserving the invariant that watcher diagnostics never expose transcript paths. - The chokidar per-provider watchers append the same remedy hint to their existing error line when the error names ENOSPC. - getGjcWatcherHealth() exposes ok/consecutiveFailures/degraded/enospc for status surfaces, and the restart schedule is a pure exported function under regression tests. Closes #42
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.
What
Fixes #42. The native session watcher supervisor retried every 30s forever when its child could not stay up. Under inotify exhaustion (ENOSPC) that produced 1752 consecutive silent failures over 14.5 hours, with discovery updates degraded the whole time and nothing actionable in the log.
How
fs.inotify.max_user_watches). Only that fixed token is retained; stderr content itself is still never forwarded, preserving the invariant that watcher diagnostics never expose transcript paths.getGjcWatcherHealth()exposesok/consecutiveFailures/degraded/enospcObservedfor status surfaces; the restart schedule is a pure exported function under regression tests.The client-visible degraded-discovery banner suggested in #42 is a UI contract change and stays open for follow-up; this PR removes the silent infinite loop and makes the failure diagnosable and self-recovering.
Verification
gjc-session-watcher.test.ts: ENOSPC token detection without leaking stderr content (path-bearing stderr never surfaces).sessions-watcher-degrade.test.ts: fast backoff below the cap (1s,2s,4s,…,30s), degraded 10-min probes at/after the cap (incl. failure 1752), health shape.