Skip to content

child_process cannot spawn native Windows executables (Rust-compiled) on Windows — hangs / ETIMEDOUT #32011

Open

Description

@JackieJK

What version of Bun is running?

1.3.14

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What steps can reproduce the bug?


// test.mjs — run with `bun test.mjs`
import { execFileSync, spawnSync } from "node:child_process";

const exe = "C:\\Users\\wo\\.local\\bin\\iii.exe";

// ❌ Hangs, then throws ETIMEDOUT
try {
  const out = execFileSync(exe, ["--version"], {
    encoding: "utf-8",
    stdio: ["ignore", "pipe", "pipe"],
    timeout: 5000,
  });
  console.log("OK:", out);
} catch (e) {
  console.log("ERR:", e.code, e.message);
}

// ❌ Also hangs, then throws ETIMEDOUT
try {
  const r = spawnSync(exe, ["--version"], {
    encoding: "utf-8",
    timeout: 5000,
  });
  console.log("spawnSync:", r.status, r.stdout?.toString());
} catch (e) {
  console.log("spawnSync ERR:", e.message);
}

// ✅ Works with shell:true
try {
  const out = execFileSync(exe, ["--version"], {
    encoding: "utf-8",
    shell: true,
    stdio: ["ignore", "pipe", "pipe"],
    timeout: 5000,
  });
  console.log("shell:true OK:", out);
} catch (e) {
  console.log("shell:true ERR:", e.message);
}

// ✅ Works via cmd /c wrapper
try {
  const out = execFileSync("cmd", ["/c", `${exe} --version`], {
    encoding: "utf-8",
    stdio: ["ignore", "pipe", "pipe"],
    timeout: 5000,
  });
  console.log("cmd/c OK:", out);
} catch (e) {
  console.log("cmd/c ERR:", e.message);
}

Actual Behavior
ERR: ETIMEDOUT The operation timed out.
spawnSync ERR: The operation timed out.
shell:true OK: 0.11.2
cmd/c OK: 0.11.2

  • execFileSync and spawnSync both hang indefinitely (timed out at 5s).
  • shell: true or cmd /c wrapper works instantly.
  • The binary itself runs fine directly from PowerShell (& path\to\iii.exe --version returns 0.11.2 immediately).

What is the expected behavior?

ERR: ETIMEDOUT The operation timed out.
spawnSync ERR: The operation timed out.
shell:true OK: 0.11.2
cmd/c OK: 0.11.2

  • execFileSync and spawnSync both hang indefinitely (timed out at 5s).
  • shell: true or cmd /c wrapper works instantly.
  • The binary itself runs fine directly from PowerShell (& path\to\iii.exe --version returns 0.11.2 immediately).
    Expected Behavior
    execFileSync and spawnSync should spawn the native Windows executable successfully without shell: true, matching Node.js behavior.

What do you see instead?

Bun-compiled binaries (via bun build --compile) that rely on child_process to spawn native Windows executables are broken on Windows without shell: true.
Reproducible with the agentmemory (https://github.com/rohitg00/agentmemory) project — its Bun-compiled CLI binary cannot start its iii-engine dependency on Windows.

Additional information

Node.js does NOT have this issue (the same agentmemory CLI works fine when run via node).
The issue is not specific to this particular binary — it likely affects any native Windows executable with a certain PE subsystem or console allocation behavior that Bun's uv_spawn-based implementation doesn't handle correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions