Skip to content

child_process#spawn breaks backward compatibility in node v4.8.0 #12117

Description

@naugtur
  • Version: v4.8.0 and up
  • Platform: Linux 4.4.0-64-generic Update README.md #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: child_process

Arguments array to spawn behaves differently between node versions up to 4.7.3 and node 4.8.0+

PoC - works as expected only in old versions. Nev node will pass 'install --production' as arguments to bash

const childProcess = require('child_process');
const spawn = childProcess.spawn;
const defaultOptions = {
  env: {},
  shell: "/bin/bash",
  stdio: [0, 1, 2]
};

const p = childProcess.spawn("/bin/bash", [ '-c', 'npm install --production' ], defaultOptions)

p.on('exit', exitCode => {
    console.log(exitCode);
});

The PoC is a short version of spawn-shell parro-it/spawn-shell#1

Activity

  1. bnoordhuis commented on Mar 29, 2017

    @bnoordhuis
    Member

    See PR #4598 and commit 5824522. The reason you see different behavior is because you pass a .shell property in options, something that wasn't supported (and was a no-op) before.

  2. naugtur commented on Mar 29, 2017

    @naugtur
    Author

    Thanks, I just found that out. It makes this an issue with spawn-shell package and semver on node is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions