Skip to content

spawnSync()'s maxBuffer option is not ignored with stdio[3]: 'ignore' #52338

Description

@ehmicky

Version

v21.7.1

Platform

Linux my-laptop 6.5.0-26-generic #26-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 5 21:19:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

child_process

What steps will reproduce the bug?

With print.js:

import {writeSync} from 'node:fs'

const fdNumber = Number(process.argv[2])
writeSync(fdNumber, 'oo') // 2 bytes, above the `maxBuffer: 1` threshold below

Then example.js:

import {spawnSync} from 'node:child_process'

const {error, output} = spawnSync('node', ['./print.js', '3'], {
  maxBuffer: 1, 
  stdio: ['pipe', 'pipe', 'pipe', 'ignore'],
})
console.log(error) // ENOBUFS
console.log(output[3]) // null

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

No.

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

Since stdio[3] is ignore, the maxBuffer option should not apply to it. I.e. the ENOBUFS error should not be present. For example, this is what happens with stdio[2].

const {error, output} = spawnSync('node', ['./print.js', '2'], {
  maxBuffer: 1, 
  stdio: ['pipe', 'pipe', 'ignore'],
})
console.log(error) // undefined
console.log(output[2]) // null

What do you see instead?

The ENOBUFS error is present.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_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