Skip to content

explorer.exe returns 1 on success — your spawn wrapper calls it failure

exit codes · case

bothmisleading-errorscriptagentfirst-partyrepro: verifiedexit-code-propagation
Affectsnode, windows
Fails asEXIT CODE LEAK
Mechanismexit code propagation
Safe fixignore handoff exit

“Reveal in folder” works — Explorer opens with the file selected — but the app logs an error every time, because execFileSync threw on a non-zero exit code.

execFileSync("explorer.exe", ["/select,", "C:\\file.txt"]);
// throws: exit code 1 — yet the window opened correctly

explorer.exe exits 1 even on success (it hands off to the running shell process and returns immediately). Exit-code-based success detection is structurally wrong for this binary.

  • Spawn detached, ignore the exit code, treat “spawn succeeded” as success (the referenced fire-and-forget fix).
  • Generalize: for Windows shell-handoff binaries (explorer, start), never encode success as exit 0.