Skip to content

doc: child_process.SpawnSync output, stdout, stderr can be null #33458

Closed
@manuel-mauky

Description

@manuel-mauky

📗 API Reference Docs Problem

  • Version: v13.9.0
  • Platform: Mac OS 10.15.4
  • Subsystem: child_process

Location

Section of the site where the content exists

Affected URL(s):

Problem description

Concise explanation of what you found to be problematic

In the "Returns" desciption it states that "stdout" and "stderr" can be <Buffer> or <string> and that "output" is of type <Array>.

However, this is not the case when the spawned process terminates with an error.
To reproduce you can run the following script:

const child_process = require("child_process")

// any command that is not available or fails with an error
const result = child_process.spawnSync("not_found") 

console.log(result)

will output:

{
  error: Error: spawnSync not_found ENOENT
      at Object.spawnSync (internal/child_process.js:1045:20)
      ...
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawnSync not_found',
    path: 'not_found',
    spawnargs: []
  },
  status: null,
  signal: null,
  output: null,
  pid: 36085,
  stdout: null,
  stderr: null
}

As you can see "stdout", "stderr" and "output" are null.
I'm not sure if this is a bug in the implementation or if this is the desired behavior. In the latter case it should be stated in the docs that these three fields can also be null and under which conditions this is the case.


  • I would like to work on this issue and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions