Repository navigation
Kill hung WSL transcript filesystem operations via child process with route quarantine - #15381
Conversation
Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms.
Review follow-ups on the sidecar isolation change:
- Only the deadline may abort running gate work. The sole waiter's
same-duration timeout fired first, killed healthy children on caller
abandonment, and settled the task before the deadline could quarantine
a stalled route - leaving the back-off dead for every dedupe:false op.
- Resolve the fork entry from out/main/chunks too: the resolver compiles
into a shared chunk, and the scanner service child has no
process.resourcesPath, so packaged WSL vault scans threw entry-not-found
(masked as an empty tree).
- Allowlist the fork env instead of spreading process.env; ambient
NODE_OPTIONS would halt or --require code into every child.
- Wrap transport faults (spawn failure, child death) in
WslTranscriptFsError('unavailable') so discovery reports them as scan
issues instead of misreading them as missing paths or empty trees.
- Gate the vitest in-process fallback on the vitest worker global so a
leaked VITEST=true cannot revert production to in-process UNC syscalls.
- Reap idle sidecar processes after 60s instead of holding them for the
app session.
- Split 'open' into its own protocol union member so the reusable-call
Exclude actually strips it from the pooled-process API.
- Guard kill('SIGKILL') against the teardown race where an exiting child
emits an unlistened 'error', and dispatch reads by handle kind before
path spelling.
Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget.
Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThe change adds a reusable child process for WSL transcript filesystem operations. It defines IPC protocol types, error handling, result decoding, process slots, handle ownership, restricted spawning, and packaged entry registration. The filesystem gate now applies deadlines and route quarantine. WSL access, reads, directory scans, and transcript tail handling use the new routing. Tests cover process reuse, handle lifecycle, quarantine behavior, stalled routes, serialization, packaging, and test-state reset. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/native-chat/wsl-transcript-fs-process-client.ts (1)
81-83: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winClassify the busy-slot rejection as a
WslTranscriptFsError.This branch rejects with a plain
Error. The comment on lines 11-13 states that discovery layers only rethrowWslTranscriptFsError, so a plain error reads as "path missing" or "empty tree" upstream. A busy slot is reachable at runtime: when a gate waiter abandons a read, the child call stays active, and a later read on the same pinned handle hits this branch. Return a classified refusal so the upstream layers treat it as a temporary condition.♻️ Proposed change
if (state.slot.active) { - return Promise.reject(new Error('WSL transcript file handle is already in use')) + return Promise.reject( + wslTranscriptFsProcessFailureError('a read on this file handle is still in flight') + ) }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 89646ed9-f432-4e00-85df-e714aff26a9f
📒 Files selected for processing (31)
config/build-plugins/plain-node-entry-guard.tsconfig/electron-builder.config.cjsconfig/scripts/electron-builder-config.test.mjselectron.vite.config.tssrc/main/ai-vault/session-scanner-core-parser-wsl-stall.test.tssrc/main/ai-vault/session-scanner-discovery-wsl-gate.test.tssrc/main/ai-vault/session-scanner-service-env.tssrc/main/native-chat/host-readable-transcript-path.tssrc/main/native-chat/transcript-read-cache.tssrc/main/native-chat/transcript-tail-boundary.tssrc/main/native-chat/transcript-tail-reader.tssrc/main/native-chat/transcript-watch-wsl-stall.test.tssrc/main/native-chat/wsl-codex-session-path-scan.tssrc/main/native-chat/wsl-transcript-fs-access.test.tssrc/main/native-chat/wsl-transcript-fs-access.tssrc/main/native-chat/wsl-transcript-fs-error.tssrc/main/native-chat/wsl-transcript-fs-gate.test.tssrc/main/native-chat/wsl-transcript-fs-gate.tssrc/main/native-chat/wsl-transcript-fs-process-client.test.tssrc/main/native-chat/wsl-transcript-fs-process-client.tssrc/main/native-chat/wsl-transcript-fs-process-decode.tssrc/main/native-chat/wsl-transcript-fs-process-dispatch.tssrc/main/native-chat/wsl-transcript-fs-process-entry.tssrc/main/native-chat/wsl-transcript-fs-process-operations.test.tssrc/main/native-chat/wsl-transcript-fs-process-operations.tssrc/main/native-chat/wsl-transcript-fs-process-protocol.tssrc/main/native-chat/wsl-transcript-fs-process-slot.tssrc/main/native-chat/wsl-transcript-fs-process-spawn.tssrc/main/native-chat/wsl-transcript-fs-route-quarantine.test.tssrc/main/native-chat/wsl-transcript-fs-route-quarantine.tssrc/main/opencode-usage/scanner-wsl-gate.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
@coderabbitai Fixing. Will be in the next commit |
|
Tip For best results, initiate chat on the files or code changes.
You are interacting with an AI system. |
A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine.
|
Heads up — this looks like it broke 4 tests on Red at The error escapes rather than degrading: Line 338 is the new Flagging rather than fixing since you own the intended semantics. Happy to take it if that helps. |
|
@Jinwoo-H will fix the tests on main |
#15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
… route quarantine (#15381) * fix(native-chat): kill hung WSL operations via child process Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms. * chore: drop internal review artifact from the repo root * fix(native-chat): harden the WSL transcript fs sidecar Review follow-ups on the sidecar isolation change: - Only the deadline may abort running gate work. The sole waiter's same-duration timeout fired first, killed healthy children on caller abandonment, and settled the task before the deadline could quarantine a stalled route - leaving the back-off dead for every dedupe:false op. - Resolve the fork entry from out/main/chunks too: the resolver compiles into a shared chunk, and the scanner service child has no process.resourcesPath, so packaged WSL vault scans threw entry-not-found (masked as an empty tree). - Allowlist the fork env instead of spreading process.env; ambient NODE_OPTIONS would halt or --require code into every child. - Wrap transport faults (spawn failure, child death) in WslTranscriptFsError('unavailable') so discovery reports them as scan issues instead of misreading them as missing paths or empty trees. - Gate the vitest in-process fallback on the vitest worker global so a leaked VITEST=true cannot revert production to in-process UNC syscalls. - Reap idle sidecar processes after 60s instead of holding them for the app session. - Split 'open' into its own protocol union member so the reusable-call Exclude actually strips it from the pooled-process API. - Guard kill('SIGKILL') against the teardown race where an exiting child emits an unlistened 'error', and dispatch reads by handle kind before path spelling. * fix(native-chat): probe stalled WSL routes instead of a fixed quarantine Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget. * fix(native-chat): harden WSL transcript fs with route quarantine strike Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules. * fix(native-chat): enforce route quarantine windows and isolate lanes per A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine. --------- Co-authored-by: OrcaWin <[email protected]> (cherry picked from commit 4ec6bbf)
…15408) * test(wsl): account for the route quarantine in stalled-mount tests #15381 added a route-level quarantine: a timed-out task blocks new admissions on that route for a back-off window, so the next real task probes recovery instead of hammering a hung mount. It merged with four tests already failing on main, and they still fail. Two causes, both test-side: - The recovery half of three tests read again immediately after releasing the stall, which the quarantine now refuses. They wait out the window, which is what a real caller does — resetting the gate would skip the admission the recovery assertions exist to prove. - `blockedRoutes` is module state that no test cleared, so a stall in one test refused an unrelated read in the next. Both files now reset the gate in beforeEach. Production behavior is unchanged and is working as designed: eviction still happens, only the immediate re-read is deferred by the back-off. * test(wsl): match the sibling suites' quarantine idiom #15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
The AI Vault title reader forks wsl-transcript-fs-process-entry.js for WSL UNC paths. PR #15381 taught electron.vite.config.ts and electron-builder to emit and unpack it for the desktop app, but config/scripts/build-relay.mjs was never updated, so no relay ever shipped it. A packaged Windows relay therefore advertised the AI Vault title service, reached the fork, threw "entry not found", and had the throw swallowed by the title reader's per-request catch — every WSL transcript title came back empty, with no error surfaced anywhere. Unit suites cannot catch this: the dispatcher runs the child's own operations in-process under vitest and never forks. The build, the content hash, and the remote install-completeness probe each carried their own hand-maintained file list, which is how the three drifted. Replace them with one declaration in src/shared/relay-artifacts.ts that all three read, and close the loop in both directions: an artifact declared but not emitted fails the build, and an artifact emitted but not declared fails it too. Each platform directory is cleared first, so a stale companion from an earlier build cannot satisfy the manifest or be hashed into .version. Adding the helper to the hash changes every relay version, so hosts install into a fresh immutable directory rather than reusing a partial one. Verified on a Windows host against a real WSL distro: the built relay returns no title before and the transcript title after, and the generated install probe accepts a complete directory and rejects one missing only the helper.
The AI Vault title reader forks wsl-transcript-fs-process-entry.js for WSL UNC paths. PR #15381 taught electron.vite.config.ts and electron-builder to emit and unpack it for the desktop app, but config/scripts/build-relay.mjs was never updated, so no relay ever shipped it. A packaged Windows relay therefore advertised the AI Vault title service, reached the fork, threw "entry not found", and had the throw swallowed by the title reader's per-request catch — every WSL transcript title came back empty, with no error surfaced anywhere. Unit suites cannot catch this: the dispatcher runs the child's own operations in-process under vitest and never forks. The build, the content hash, and the remote install-completeness probe each carried their own hand-maintained file list, which is how the three drifted. Replace them with one declaration in src/shared/relay-artifacts.ts that all three read, and close the loop in both directions: an artifact declared but not emitted fails the build, and an artifact emitted but not declared fails it too. Each platform directory is cleared first, so a stale companion from an earlier build cannot satisfy the manifest or be hashed into .version. Adding the helper to the hash changes every relay version, so hosts install into a fresh immutable directory rather than reusing a partial one. Verified on a Windows host against a real WSL distro: the built relay returns no title before and the transcript title after, and the generated install probe accepts a complete directory and rejects one missing only the helper.
… route quarantine (#15381) * fix(native-chat): kill hung WSL operations via child process Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms. * chore: drop internal review artifact from the repo root * fix(native-chat): harden the WSL transcript fs sidecar Review follow-ups on the sidecar isolation change: - Only the deadline may abort running gate work. The sole waiter's same-duration timeout fired first, killed healthy children on caller abandonment, and settled the task before the deadline could quarantine a stalled route - leaving the back-off dead for every dedupe:false op. - Resolve the fork entry from out/main/chunks too: the resolver compiles into a shared chunk, and the scanner service child has no process.resourcesPath, so packaged WSL vault scans threw entry-not-found (masked as an empty tree). - Allowlist the fork env instead of spreading process.env; ambient NODE_OPTIONS would halt or --require code into every child. - Wrap transport faults (spawn failure, child death) in WslTranscriptFsError('unavailable') so discovery reports them as scan issues instead of misreading them as missing paths or empty trees. - Gate the vitest in-process fallback on the vitest worker global so a leaked VITEST=true cannot revert production to in-process UNC syscalls. - Reap idle sidecar processes after 60s instead of holding them for the app session. - Split 'open' into its own protocol union member so the reusable-call Exclude actually strips it from the pooled-process API. - Guard kill('SIGKILL') against the teardown race where an exiting child emits an unlistened 'error', and dispatch reads by handle kind before path spelling. * fix(native-chat): probe stalled WSL routes instead of a fixed quarantine Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget. * fix(native-chat): harden WSL transcript fs with route quarantine strike Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules. * fix(native-chat): enforce route quarantine windows and isolate lanes per A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine. --------- Co-authored-by: OrcaWin <[email protected]>
…15408) * test(wsl): account for the route quarantine in stalled-mount tests #15381 added a route-level quarantine: a timed-out task blocks new admissions on that route for a back-off window, so the next real task probes recovery instead of hammering a hung mount. It merged with four tests already failing on main, and they still fail. Two causes, both test-side: - The recovery half of three tests read again immediately after releasing the stall, which the quarantine now refuses. They wait out the window, which is what a real caller does — resetting the gate would skip the admission the recovery assertions exist to prove. - `blockedRoutes` is module state that no test cleared, so a stall in one test refused an unrelated read in the next. Both files now reset the gate in beforeEach. Production behavior is unchanged and is working as designed: eviction still happens, only the immediate re-read is deferred by the back-off. * test(wsl): match the sibling suites' quarantine idiom #15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
… route quarantine (stablyai#15381) * fix(native-chat): kill hung WSL operations via child process Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms. * chore: drop internal review artifact from the repo root * fix(native-chat): harden the WSL transcript fs sidecar Review follow-ups on the sidecar isolation change: - Only the deadline may abort running gate work. The sole waiter's same-duration timeout fired first, killed healthy children on caller abandonment, and settled the task before the deadline could quarantine a stalled route - leaving the back-off dead for every dedupe:false op. - Resolve the fork entry from out/main/chunks too: the resolver compiles into a shared chunk, and the scanner service child has no process.resourcesPath, so packaged WSL vault scans threw entry-not-found (masked as an empty tree). - Allowlist the fork env instead of spreading process.env; ambient NODE_OPTIONS would halt or --require code into every child. - Wrap transport faults (spawn failure, child death) in WslTranscriptFsError('unavailable') so discovery reports them as scan issues instead of misreading them as missing paths or empty trees. - Gate the vitest in-process fallback on the vitest worker global so a leaked VITEST=true cannot revert production to in-process UNC syscalls. - Reap idle sidecar processes after 60s instead of holding them for the app session. - Split 'open' into its own protocol union member so the reusable-call Exclude actually strips it from the pooled-process API. - Guard kill('SIGKILL') against the teardown race where an exiting child emits an unlistened 'error', and dispatch reads by handle kind before path spelling. * fix(native-chat): probe stalled WSL routes instead of a fixed quarantine Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget. * fix(native-chat): harden WSL transcript fs with route quarantine strike Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules. * fix(native-chat): enforce route quarantine windows and isolate lanes per A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine. --------- Co-authored-by: OrcaWin <[email protected]>
…tablyai#15408) * test(wsl): account for the route quarantine in stalled-mount tests stablyai#15381 added a route-level quarantine: a timed-out task blocks new admissions on that route for a back-off window, so the next real task probes recovery instead of hammering a hung mount. It merged with four tests already failing on main, and they still fail. Two causes, both test-side: - The recovery half of three tests read again immediately after releasing the stall, which the quarantine now refuses. They wait out the window, which is what a real caller does — resetting the gate would skip the admission the recovery assertions exist to prove. - `blockedRoutes` is module state that no test cleared, so a stall in one test refused an unrelated read in the next. Both files now reset the gate in beforeEach. Production behavior is unchanged and is working as designed: eviction still happens, only the immediate re-read is deferred by the back-off. * test(wsl): match the sibling suites' quarantine idiom stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
… route quarantine (stablyai#15381) * fix(native-chat): kill hung WSL operations via child process Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms. * chore: drop internal review artifact from the repo root * fix(native-chat): harden the WSL transcript fs sidecar Review follow-ups on the sidecar isolation change: - Only the deadline may abort running gate work. The sole waiter's same-duration timeout fired first, killed healthy children on caller abandonment, and settled the task before the deadline could quarantine a stalled route - leaving the back-off dead for every dedupe:false op. - Resolve the fork entry from out/main/chunks too: the resolver compiles into a shared chunk, and the scanner service child has no process.resourcesPath, so packaged WSL vault scans threw entry-not-found (masked as an empty tree). - Allowlist the fork env instead of spreading process.env; ambient NODE_OPTIONS would halt or --require code into every child. - Wrap transport faults (spawn failure, child death) in WslTranscriptFsError('unavailable') so discovery reports them as scan issues instead of misreading them as missing paths or empty trees. - Gate the vitest in-process fallback on the vitest worker global so a leaked VITEST=true cannot revert production to in-process UNC syscalls. - Reap idle sidecar processes after 60s instead of holding them for the app session. - Split 'open' into its own protocol union member so the reusable-call Exclude actually strips it from the pooled-process API. - Guard kill('SIGKILL') against the teardown race where an exiting child emits an unlistened 'error', and dispatch reads by handle kind before path spelling. * fix(native-chat): probe stalled WSL routes instead of a fixed quarantine Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget. * fix(native-chat): harden WSL transcript fs with route quarantine strike Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules. * fix(native-chat): enforce route quarantine windows and isolate lanes per A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine. --------- Co-authored-by: OrcaWin <[email protected]>
…tablyai#15408) * test(wsl): account for the route quarantine in stalled-mount tests stablyai#15381 added a route-level quarantine: a timed-out task blocks new admissions on that route for a back-off window, so the next real task probes recovery instead of hammering a hung mount. It merged with four tests already failing on main, and they still fail. Two causes, both test-side: - The recovery half of three tests read again immediately after releasing the stall, which the quarantine now refuses. They wait out the window, which is what a real caller does — resetting the gate would skip the admission the recovery assertions exist to prove. - `blockedRoutes` is module state that no test cleared, so a stall in one test refused an unrelated read in the next. Both files now reset the gate in beforeEach. Production behavior is unchanged and is working as designed: eviction still happens, only the immediate re-read is deferred by the back-off. * test(wsl): match the sibling suites' quarantine idiom stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
… route quarantine (stablyai#15381) * fix(native-chat): kill hung WSL operations via child process Stalled UNC file operations hold libuv permits even after the gate timeout expires, blocking Chat tab recovery. Two stalled operations fill both permits and freeze all WSL access until restart. Fork file I/O for UNC paths into a separate child process. On deadline expiry, kill the process to force the hung syscall to exit. This frees the permit for the affected tab's next read. Temporarily quarantine the stalled route to avoid retry storms. * chore: drop internal review artifact from the repo root * fix(native-chat): harden the WSL transcript fs sidecar Review follow-ups on the sidecar isolation change: - Only the deadline may abort running gate work. The sole waiter's same-duration timeout fired first, killed healthy children on caller abandonment, and settled the task before the deadline could quarantine a stalled route - leaving the back-off dead for every dedupe:false op. - Resolve the fork entry from out/main/chunks too: the resolver compiles into a shared chunk, and the scanner service child has no process.resourcesPath, so packaged WSL vault scans threw entry-not-found (masked as an empty tree). - Allowlist the fork env instead of spreading process.env; ambient NODE_OPTIONS would halt or --require code into every child. - Wrap transport faults (spawn failure, child death) in WslTranscriptFsError('unavailable') so discovery reports them as scan issues instead of misreading them as missing paths or empty trees. - Gate the vitest in-process fallback on the vitest worker global so a leaked VITEST=true cannot revert production to in-process UNC syscalls. - Reap idle sidecar processes after 60s instead of holding them for the app session. - Split 'open' into its own protocol union member so the reusable-call Exclude actually strips it from the pooled-process API. - Guard kill('SIGKILL') against the teardown race where an exiting child emits an unlistened 'error', and dispatch reads by handle kind before path spelling. * fix(native-chat): probe stalled WSL routes instead of a fixed quarantine Remaining review follow-ups: - Escalating route quarantine: first strike lifts after 5s so a distro that was cold-booting when its op hit the deadline recovers on the next poll (~35s total instead of ~90s); repeat stalls double the back-off toward the prior 2x-timeout cap, and any settle the deadline did not force clears the strikes. Queued same-route tasks fail fast at quarantine instead of stranding one waiter deadline per file in sequential scans. - Single request implementation: the vitest in-process fallback now runs the child's own dispatcher (WslTranscriptFsProcessOperations + decode), so unit suites exercise exactly what the forked process executes and the per-call-site fallback closures are gone. Dirent fixtures gained the full kind-flag set the serializer reads. - Dropped the production-dead per-route close queue; UNC FileHandles (test fallback only) mirror the process-handle close contract. - Error class, messages, and factories move to wsl-transcript-fs-error (re-exported from the gate) to keep the gate under the lines budget. * fix(native-chat): harden WSL transcript fs with route quarantine strike Extract quarantine logic into a dedicated module with strike decay: stalls older than 5 minutes restart from base back-off, and concurrent-lane timeouts count as one incident. Allow joining live in-flight tasks on quarantined routes (they cost no new I/O). Preserve quarantine across transport faults (child death). Handle file shrinking during tail reads by detecting short reads and returning empty. Defer file closes that arrive mid-read instead of refusing, preventing slot leaks. Separate process slot and boundary-finding concerns into focused modules. * fix(native-chat): enforce route quarantine windows and isolate lanes per A late result arriving after the deadline was incorrectly lifting the route quarantine, allowing subsequent work to start before the back-off period expired. Now late results are correctly recognized as stale and never cut the quarantine short. Process work is now isolated per (route, priority) lane so a scan stall cannot block exact reads on the same distro. Each lane gets its own client and process pool; late results and handle faults stay scoped to their lane. Tests now fake performance.now() alongside timers (the quarantine clock depends on it) and wait for the full back-off window to expire rather than advancing by 0. Gate state is reset between test cases since late releases never lift the quarantine. --------- Co-authored-by: OrcaWin <[email protected]>
…tablyai#15408) * test(wsl): account for the route quarantine in stalled-mount tests stablyai#15381 added a route-level quarantine: a timed-out task blocks new admissions on that route for a back-off window, so the next real task probes recovery instead of hammering a hung mount. It merged with four tests already failing on main, and they still fail. Two causes, both test-side: - The recovery half of three tests read again immediately after releasing the stall, which the quarantine now refuses. They wait out the window, which is what a real caller does — resetting the gate would skip the admission the recovery assertions exist to prove. - `blockedRoutes` is module state that no test cleared, so a stall in one test refused an unrelated read in the next. Both files now reset the gate in beforeEach. Production behavior is unchanged and is working as designed: eviction still happens, only the immediate re-read is deferred by the back-off. * test(wsl): match the sibling suites' quarantine idiom stablyai#15381 applied this same fix to session-scanner-core-parser-wsl-stall, session-scanner-discovery-wsl-gate, and opencode-usage/scanner-wsl-gate, and missed these two files. Adopt that established shape rather than a parallel one: fold the back-off wait into releaseAndSettle instead of a separate helper at each call site, and fake performance explicitly, since performance.now drives the quarantine clock. The explicit toFake is not strictly required today — vitest's default already fakes performance — but it documents the dependency and stops a default change from silently unfaking the quarantine clock.
Problem
WSL UNC filesystem operations that stall indefinitely can exhaust the main process's libuv thread pool. Two blocked syscalls on a hung mount burn both permits, causing global unavailability. There is no way to interrupt an unabortable 9P syscall.
Solution
Fork filesystem operations on WSL UNC paths to a child process (ELECTRON_RUN_AS_NODE). Kill the child if the operation exceeds its deadline (30s exact, 60s scan). Implement route-level quarantine with exponential backoff to avoid hammering a hung mount after the first stall. Lift quarantine on successful operations; escalate on repeat stalls with strike decay after 5 minutes of quiet. Serialize Dirent and Stats through IPC since they lose prototype methods across process boundaries.
What Changed
wsl-transcript-fs-process-*modules: child entry point, client connection pool, request/response protocol, slot management, spawn/fork config, and operation handlerswsl-transcript-fs-route-quarantine.ts: per-route blocking with exponential back-off and strike decaywsl-transcript-fs-error.tsso they work across process boundarieswsl-transcript-fs-access.tsto delegate UNC operations through the child dispatcherVerification
New test suites cover: process client lifecycle, handle pinning, idle reap, transport faults, error reconstruction; route quarantine escalation, decay, and sibling-lane deduplication. Existing gate and access tests updated to reset route quarantine per-test and validate the new process-based UNC paths.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover)