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
@@ -190,6 +191,16 @@ The watch client (`client/watch.rs`) uses a **daemon-driven** watching strategy:
190
191
191
192
**Signal handling:** Watch client uses `tokio::signal::unix` to handle SIGTERM/SIGINT. On signal, sends `DisconnectRequest` to daemon before exiting cleanly.
192
193
194
+
**Reconnection:** On gRPC stream errors, the watch client automatically reconnects:
195
+
196
+
-`run()` wraps each session in a retry loop with exponential backoff (1s → 2s → 4s → ... → 30s cap)
197
+
-`run_watch_session()` returns `SessionExit::Clean` (signal, no retry) or `SessionExit::StreamError` (retry)
198
+
- On reconnect, `connect_or_start()` handles starting a new daemon if the old one died
199
+
- File watchers are recreated fresh via `WatchPaths` event each session — no state carryover needed
200
+
- Logs the last event received before the error for diagnostics
201
+
202
+
**Heartbeat:** Daemon sends `Heartbeat` event every 30s on the watch stream. This ensures broken connections are detected even during idle periods (no build activity). The heartbeat write failing on the server side triggers tonic to drop the stream, firing `scopeguard` cleanup.
- HTTP/2 keepalive: `http2_keepalive_interval(10s)` + `http2_keepalive_timeout(5s)` on tonic server — detects dead clients within ~15s even if no application traffic
202
214
- Writes PID to `<root>/lib/bs/rescript.daemon.pid`
203
215
- Writes socket path to `<root>/lib/bs/rescript.sock.path`
204
216
- Cleans up socket, PID file, and socket path file on exit
@@ -312,6 +324,7 @@ Update after each session. Reflect current state, not history.
312
324
-**std::sync::Mutex in async**: Works because locking only in `spawn_blocking`, but footgun
313
325
-**No protocol versioning**: Client/daemon must be same version
314
326
-**Unix-only**: No Windows support (needs named pipes or TCP)
327
+
-**Reconnection is watch-only**: Build/clean/format clients don't retry on stream errors (they're short-lived, so restart is acceptable)
0 commit comments