Skip to content

Commit 5e45d16

Browse files
fix(process): unexport Windows spawn sanitizer for knip
Keep the win32 detached:false guard internal to spawnWithFallback so knip no longer flags an unused export, and drop direct helper tests that tripped check-test-types on readonly stdio tuples. Co-authored-by: Cursor <[email protected]>
1 parent a57d44c commit 5e45d16

2 files changed

Lines changed: 5 additions & 29 deletions

File tree

src/process/spawn-utils.test.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ChildProcess, SpawnOptions } from "node:child_process";
33
import { EventEmitter } from "node:events";
44
import { PassThrough } from "node:stream";
55
import { describe, expect, it, vi } from "vitest";
6-
import { sanitizeSpawnOptionsForPlatform, spawnWithFallback } from "./spawn-utils.js";
6+
import { spawnWithFallback } from "./spawn-utils.js";
77

88
function createStubChild() {
99
const child = new EventEmitter() as ChildProcess;
@@ -34,31 +34,6 @@ function spawnOptionsAt(
3434
return options as SpawnOptions;
3535
}
3636

37-
describe("sanitizeSpawnOptionsForPlatform", () => {
38-
it("forces detached false on Windows when callers request detached true (#105528)", () => {
39-
const sanitized = sanitizeSpawnOptionsForPlatform(
40-
{ detached: true, stdio: ["pipe", "pipe", "pipe"], windowsHide: true },
41-
"win32",
42-
);
43-
expect(sanitized.detached).toBe(false);
44-
expect(sanitized.windowsHide).toBe(true);
45-
expect(sanitized.stdio).toEqual(["pipe", "pipe", "pipe"]);
46-
});
47-
48-
it("leaves detached true alone on POSIX", () => {
49-
const sanitized = sanitizeSpawnOptionsForPlatform(
50-
{ detached: true, stdio: ["ignore", "pipe", "pipe"] },
51-
"linux",
52-
);
53-
expect(sanitized.detached).toBe(true);
54-
});
55-
56-
it("leaves already-attached Windows options unchanged", () => {
57-
const options = { detached: false, stdio: ["pipe", "pipe", "pipe"] as const };
58-
expect(sanitizeSpawnOptionsForPlatform(options, "win32")).toBe(options);
59-
});
60-
});
61-
6237
describe("spawnWithFallback", () => {
6338
it("retries on EBADF using fallback options", async () => {
6439
const spawnMock = vi

src/process/spawn-utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ const DEFAULT_RETRY_CODES = ["EBADF"];
2929
/**
3030
* On Windows, `detached: true` can break stdout/stderr pipe capture for
3131
* headless hosts (Scheduled Task / service) so exec/read-style tools return
32-
* empty output with no error. Call sites mostly opt out already; keep a
33-
* central belt-and-suspenders guard so every spawnWithFallback caller is safe.
32+
* empty output with no error. The sole production caller
33+
* (`createChildAdapter`) already opts out on win32; keep this as a local
34+
* guard so future spawnWithFallback callers cannot reintroduce the footgun.
3435
* See #105528 / historical #17806 / #18035.
3536
*/
36-
export function sanitizeSpawnOptionsForPlatform(
37+
function sanitizeSpawnOptionsForPlatform(
3738
options: SpawnOptions,
3839
platform: NodeJS.Platform = process.platform,
3940
): SpawnOptions {

0 commit comments

Comments
 (0)