Repository navigation
cherry-pick: kill hung WSL transcript fs operations via child process (#15381) for 1.8.185-cb42b60 [STA-4360] - #15392
Closed
AmethystLiang wants to merge 1 commit into
Closed
AmethystLiang wants to merge 1 commit into
AmethystLiang wants to merge 1 commit into
Conversation
… 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)
9 tasks done
Contributor
Author
|
Closing staging PR; cherry-pick #15381 will be applied directly to the assembled adhoc branch as tracked in STA-4816. |
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.
Cherry-pick
Cherry-pick of #15381 — "Kill hung WSL transcript filesystem operations via child process with route quarantine" — onto the
1.8.185adhoc branch for the Release-08-15-2026 ·cb42b60cut.4ec6bbf5884e5bd915b4f49c4602b5e5a88b61aecb42b60849d81ff58976200baa6b89dc5df99fb7adhoc/1.8.185-cb42b60(tipe0fb833ec0)Why this is needed on the cut
Two never-settling WSL UNC/9P calls exhaust both scheduler permits for the process lifetime, after which no WSL transcript I/O ever starts — transcript chat, watchers, and AI Vault discovery stall across all healthy distros.
The defect is in
wsl-transcript-fs-gate.ts:settleTaskis the only path that removes a task fromactiveTasks, and the stuck deadline (stuckTimer) only setstask.stuck = trueand logs — it never releases the permit. Once both permits are held by unabortable syscalls,pumpTasks()can never admit another task andstuckBlockerglobally fast-fails every new one.#15381 fixes this by forking UNC filesystem operations to a child process (
ELECTRON_RUN_AS_NODE) that can actually be killed when its deadline expires (30s exact / 60s scan), plus per-route quarantine with exponential backoff and strike decay.Attribution note
The defect originated in #14090 (
7b326e212f, "Gate WSL transcript fs ops with timeout and capacity limits"), not in #14203 as the release tickets currently state.git blameon the exhaustion lines (wsl-transcript-fs-gate.ts:143-145,:196,:271) points at7b326e212f. #14203 widened gating fromaccess|readdirtostat|lstat|open|read|readfileacross 34 source files, which made the latent defect reachable in practice — hence the misattribution. Both are ancestors of the pinned base, so this pick is the correct remedy either way; reverting #14203 would not have fixed it.Verification on this base
scanner-wsl-gate.test.tsimportslistOpenCodeDatabasesfrom./scanneron this base (main later moved it toopencode-database-discovery.ts). Git's 3-way merge kept the base's path correctly; the symbol is exported atsrc/main/opencode-usage/scanner.ts:83.src/main/native-chat/betweencb42b60and the fix, so there is no interleaving risk.electron.vite.config.ts:226,config/electron-builder.config.cjs:192(asarUnpack),config/build-plugins/plain-node-entry-guard.ts:26.pnpm lint/typecheck/test/build— deferred to PR CI on this branch.Release-process caveat
Per
adhoc-build-release-checklist.md, the hard authorization gate is not currently satisfied for this cut:adhoc-build-1.8.185.mdrecords the state as "blocked before build authorization", pending an authoritative ordered live-pick list and the#14366/orca-cloud#370companion decision. That blocker is about pick ordering and scope, not about this fix.This PR does not build, dispatch, or soak anything — it only stages the P1 pick for review. Do not dispatch an adhoc build from the merged result until the ordered pick list is recorded and this pick is added to it.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover)