Skip to content

fix: contain watcher EMFILE runtime crashes#395

Merged
Anton-Horn merged 2 commits into
0-AI-UG:mainfrom
Ruderud:fix/runtime-watch-epipe-emfile
Jun 16, 2026
Merged

fix: contain watcher EMFILE runtime crashes#395
Anton-Horn merged 2 commits into
0-AI-UG:mainfrom
Ruderud:fix/runtime-watch-epipe-emfile

Conversation

@Ruderud

@Ruderud Ruderud commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #394.

This PR makes filesystem watcher failures recoverable instead of allowing them to cascade into a fatal Electron main-process write EPIPE dialog.

Changes:

  • Pool daemon file.watch subscriptions under an existing covering watcher root to avoid duplicate full-tree chokidar watchers for the same workspace.
  • Contain daemon and main-process chokidar error events, close the broken watcher, and allow a later watch request to recreate it.
  • Guard local and WSL runtime stdin writes after the daemon exits so closed pipes fail as normal runtime request failures instead of uncaught EPIPE exceptions.
  • Add regression tests for watcher pooling, watcher error recovery, and post-exit stdin writes.

Validation

npx vitest run src/main/ipc/fsWatchError.test.ts src/runtime/capabilities/watchPool.test.ts src/main/runtime/transports/localTransport.dispose.test.ts
npx eslint src/main/ipc/filesystem.ts src/main/ipc/fsWatchError.test.ts src/runtime/capabilities/index.ts src/runtime/capabilities/watchPool.test.ts src/main/runtime/transports/localTransport.ts src/main/runtime/transports/localTransport.dispose.test.ts src/main/runtime/transports/wslTransport.ts
npm run typecheck

@Ruderud Ruderud force-pushed the fix/runtime-watch-epipe-emfile branch from 6048e32 to 426c559 Compare June 16, 2026 00:58
@Ruderud Ruderud force-pushed the fix/runtime-watch-epipe-emfile branch from 426c559 to 179d052 Compare June 16, 2026 01:00
@Ruderud Ruderud marked this pull request as ready for review June 16, 2026 01:07
@Anton-Horn

Copy link
Copy Markdown
Contributor

ran the tests + typecheck locally, all green. handlers are code-agnostic so ENOSPC (the inotify limit you hit on linux for big repos) recovers too, just no test for it. fine to add later. merging.

validatePath() returns path.resolve(p), so '/repo' becomes a drive-prefixed
backslash path on Windows and the hardcoded POSIX event paths never matched
the subscriber prefix. Derive ROOT/SRC/file paths from path.resolve/join.
@Anton-Horn Anton-Horn merged commit 98f6e21 into 0-AI-UG:main Jun 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local runtime can crash with EMFILE/EPIPE when watching large workspaces

2 participants