Repository navigation
fix(lib): wait for a killed subprocess to die before abandoning it #4825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78ba06f
298062d
95da496
1504caa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ | |
|
|
||
| import { existsSync, statSync } from "node:fs"; | ||
| import { env, platform } from "node:process"; | ||
| import { waitForSubprocessExit } from "./bounded-subprocess"; | ||
| import { SUBPROCESS_KILL_GRACE_MS, waitForSubprocessExit } from "./bounded-subprocess"; | ||
| import { resolveTrustedWindowsIcaclsExe } from "./windows-elevation"; | ||
| import { | ||
| cachedCurrentWindowsIdentity, | ||
|
|
@@ -48,6 +48,8 @@ const hardenedPaths = new Map<string, HardenedIdentity>(); | |
| * that attempt was consumed. Ordinary callers never consume it. | ||
| */ | ||
| const timedOutPaths = new Map<string, boolean>(); | ||
| /** Slack above the kill grace so the outer belt can never fire before the runner settles. */ | ||
| const ASYNC_ICACLS_BELT_MARGIN_MS = 250; | ||
|
|
||
| /** | ||
| * The memo value: `object:freshness` for a file a harden was actually attributed | ||
|
|
@@ -366,9 +368,13 @@ function awaitAsyncIcaclsRunner(args: string[], timeoutMs: number): Promise<Icac | |
| if (timer !== undefined) clearTimeout(timer); | ||
| resolve(result); | ||
| }; | ||
| // The belt has to outlast the runner it is guarding, or it is not a belt -- it is the | ||
| // deadline. At exactly `timeoutMs` this used to resolve while `waitForSubprocessExit` was | ||
| // still killing the child, which reintroduced the abandonment that helper now avoids: the | ||
| // caller saw a settled flight and started removing a directory `icacls.exe` still held. | ||
| timer = setTimeout( | ||
| () => finish({ success: false, exitCode: null, timedOut: true, stdout: "" }), | ||
| Math.max(1, timeoutMs), | ||
| Math.max(1, timeoutMs) + SUBPROCESS_KILL_GRACE_MS + ASYNC_ICACLS_BELT_MARGIN_MS, | ||
|
Comment on lines
375
to
+377
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the event loop is blocked until both timers are overdue, Useful? React with 👍 / 👎. |
||
| ); | ||
| void asyncIcaclsRunner(args, timeoutMs).then(finish, () => finish(spawnFailedResult())); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes subprocess timeout semantics in
src/lib/and native-main lifecycle behavior insrc/codex/, but the commit updates none of the structure documents that own those areas. Update the documents mapped to these source areas so the documented lifecycle and teardown invariants remain synchronized with the implementation.AGENTS.md reference: src/AGENTS.md:L10-L11
Useful? React with 👍 / 👎.