fix(windows): preserve transfer cleanup after cancellation

This commit is contained in:
Zhang GH
2026-09-08 20:04:24 +08:00
parent caea98cd52
commit 0822c53c65
6 changed files with 301 additions and 89 deletions
@@ -71,8 +71,9 @@ export interface BskRunner {
// Business RPCs translate Ctrl-C / opt-in stdin EOF into cancel(rpc_id).
// Allow reconciliation before hard-killing an old or unresponsive CLI.
const KILL_GRACE_MS = 3000;
// Windows IPC may spend 5s connecting, then 2s cancelling and 2s settling.
const WINDOWS_KILL_GRACE_MS = 10_000;
// Windows IPC may spend 5s connecting, 2s cancelling, 2s settling,
// and up to 5s releasing the entire batch of caller-owned transfers.
const WINDOWS_KILL_GRACE_MS = 15_000;
const SESSION_BUSY_RETRY_DELAY_MS = 100;
export function createBskRunner(bskPath: string, spawnImpl: SpawnImpl = spawn): BskRunner {
@@ -133,6 +133,8 @@ describe("Windows parent cancellation", () => {
expect(child.stdin.writableEnded).toBe(true);
expect(child.killedWith).toEqual([]);
await vi.advanceTimersByTimeAsync(10_000);
expect(child.killedWith).toEqual([]);
await vi.advanceTimersByTimeAsync(5_000);
expect(child.killedWith).toEqual(["SIGKILL"]);
expect(await result).toMatchObject({ timedOut: true });
});