Skip to content

process.execve's args argument should be optional #58411

@mureinik

Description

@mureinik

Version

24.0.2

Platform

Darwin BD-MB61360 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020 arm64

Subsystem

process

What steps will reproduce the bug?

Run process.execve without the args argument:

$ node -e 'process.execve("/bin/ls")'

How often does it reproduce? Is there a required condition?

Reproduces consistently with the snippet given in the previous section

What is the expected behavior? Why is that the expected behavior?

According to the documentation (see https://nodejs.org/api/process.html#processexecvefile-args-env), the args argument should be optional, and you should be able to omit it. This isn't documented explicitly, but based on similar methods such as child_process.spawn, I'd expect a missing args argument to be treated as an empty array ([]).

What do you see instead?

The call fails with an ERR_INVALID_ARG_TYPE TypeError:

$ node -e 'process.execve("/bin/ls")'       
node:internal/errors:540
      throw error;
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "args" argument must be an instance of Array. Received undefined
    at process.execve (node:internal/process/per_thread:294:5)
    at [eval]:1:9
    at runScriptInThisContext (node:internal/vm:218:10)
    at node:internal/process/execution:456:12
    at [eval]-wrapper:6:24
    at runScriptInContext (node:internal/process/execution:454:60)
    at evalFunction (node:internal/process/execution:286:30)
    at evalTypeScript (node:internal/process/execution:298:3)
    at node:internal/main/eval_string:71:3 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    processIssues and PRs related to the process subsystem.

    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