Skip to content

node:child_process — exec/execFile failure Error missing .code/.signal/.killed/.cmd #1935

@proggeramlug

Description

@proggeramlug

Summary

When exec/execFile run a command that exits non-zero, the (err, stdout, stderr) callback fires with a bare Error("Command failed"). Node attaches diagnostic properties that callers routinely read.

Verified against node --experimental-strip-types:

cp.exec("exit 3", (e) => { /* Object.keys(e) → */ "code,killed,signal,cmd" });
// e.code === 3   e.killed === false   e.signal === null   e.cmd === "exit 3"

Today (perry 0.5.1029) e.code/e.killed/e.signal/e.cmd are all undefined.

What to do

  • On non-zero exit, populate the callback Error with code (numeric exit code, or the signal name when killed by signal), signal (string | null), killed (boolean), and cmd (the command string; for execFile, file + args).
  • On spawn failure (e.g. ENOENT), Node sets code to the errno string ("ENOENT") plus errno/syscall/path — worth matching too.

The error is built in js_child_process_exec / js_child_process_exec_file in crates/perry-runtime/src/child_process.rs (currently js_error_new_with_message("Command failed")).

Parent: #1780. perry 0.5.1029.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparityNode.js compatibility / parity gaps

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions