pi-mono/packages/env/daemon
robopipi[bot] 102d128713
fix(env): report watch overflow when a change list exceeds the frame limit (#11605)
After a rescan, the env daemon's file watcher sent every changed path in
a single `change` event. When a big batch of changes made that event
larger than the 16 MiB frame limit, `write_frame` rejected it. The
daemon's only output writer then shut down. The daemon process kept
running but sent no more replies or pings. Requests hung until the
client's 30 s silence limit dropped the connection and reconnected.

Now the watcher builds the event with `change_event`. If the serialized
path list would not fit in a frame (`MAX_PAYLOAD`), it sends the
existing `{ kind: "change", overflow: true }` event in its place. The
client already maps that to an `overflow` file change, so the wire
format does not change and the connection keeps working.

Testing:
- Added Rust unit tests in `watch.rs`. One checks that a small path list
is sent as `paths`. The other checks that a list larger than
`MAX_PAYLOAD` becomes `overflow`.
- `cargo fmt --check`, `cargo clippy --locked --all-targets -- -D
warnings` and `cargo test --locked` pass in `packages/env/daemon`.
- The `packages/env` vitest suite passes.
- Reproduced with the real daemon: I watched a directory and renamed in
a directory of 6,000 files with long paths, about 20 MB of path JSON.
Before the change, `fileInfo` requests timed out from the flush until
the client reconnected about 30 s later. After the change, the watcher
reports `overflow` right away and `fileInfo` keeps working. With 3,000
files, which fits in a frame, the paths are still reported as before.

Fixes #10516

Requested by @badlogic

Co-authored-by: triagent <triagent@localhost>
2026-10-30 12:15:09 +01:00
..
src fix(env): report watch overflow when a change list exceeds the frame limit (#11605) 2026-10-30 12:15:09 +01:00
build.rs fix(env): daemon robustness, output windows, native watching and Node read semantics 2026-10-05 17:32:22 +02:00
Cargo.lock feat(env): listFiles operation in the pi-env daemon 2026-10-12 15:22:14 +00:00
Cargo.toml feat(env): listFiles operation in the pi-env daemon 2026-10-12 15:22:14 +00:00
rust-toolchain.toml feat(env): add @earendil-works/pi-env, remote execution environments over SSH 2026-10-05 12:50:48 +02:00