Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
manuel-mauky opened this issue May 18, 2020 · 2 comments
Closed
1 task

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

manuel-mauky opened this issue May 18, 2020 · 2 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@manuel-mauky
Copy link

📗 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.
@manuel-mauky manuel-mauky added the doc Issues and PRs related to the documentations. label May 18, 2020
jasnell added a commit to jasnell/node that referenced this issue Jan 4, 2021
The various `subprocess.stdwhatever` properties can be null or
undefined in certain conditions.

Fixes: nodejs#33458
Signed-off-by: James M Snell <[email protected]>
@jasnell jasnell closed this as completed in 8ce6583 Jan 7, 2021
danielleadams pushed a commit that referenced this issue Jan 12, 2021
The various `subprocess.stdwhatever` properties can be null or
undefined in certain conditions.

Fixes: #33458
Signed-off-by: James M Snell <[email protected]>

PR-URL: #36784
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this issue May 1, 2021
The various `subprocess.stdwhatever` properties can be null or
undefined in certain conditions.

Fixes: #33458
Signed-off-by: James M Snell <[email protected]>

PR-URL: #36784
Reviewed-By: Luigi Pinca <[email protected]>
@meglio
Copy link

meglio commented May 26, 2021

This is still a problem for me in 16.2, installed via nvm in MacOS Big Sur.

spawnSync with no options successfully catches stdout and stderr.

spawnSync with a single option, e.g. {env}, returns an object with status, signal, output, stdout, and stderrall set tonull`.

@eherozhao
Copy link

I am also seeing this issue with 16.14. My spawnSync is running a command with longer time and nothing print out.

0x2b3bfa0 added a commit to iterative/cml that referenced this issue Jan 4, 2023
0x2b3bfa0 added a commit to iterative/cml that referenced this issue Jan 17, 2023
* Output a meaningful message if `git` is not available

Related to nodejs/node#33458

* Lint

* Lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants