Skip to content

node:child_process — exec/execFile/sync ignore the encoding option (no Buffer stdout/stderr) #1937

@proggeramlug

Description

@proggeramlug

Summary

exec / execFile (and the sync forms) ignore the encoding option. Node defaults to "utf8" (so the callback stdout/stderr are strings), but encoding: "buffer" or encoding: null makes them Buffers.

Today (perry 0.5.1029) js_child_process_exec / js_child_process_exec_file always box stdout/stderr as strings (box_string), so { encoding: "buffer" } still yields strings.

What to do

  • Read encoding from the options object. For "buffer"/null, pass stdout/stderr as Buffers to the callback (and return a Buffer from the no-callback / sync forms); otherwise decode with the named encoding (utf8 default).
  • Applies to exec, execFile, execSync, execFileSync, and ties into the spawnSync Buffer-vs-string default.

Parent: #1780. perry 0.5.1029.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestparityNode.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