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

ERROR: build:before: None-Zero Exit(7); #14

Closed
e-jigsaw opened this issue Nov 18, 2015 · 10 comments
Closed

ERROR: build:before: None-Zero Exit(7); #14

e-jigsaw opened this issue Nov 18, 2015 · 10 comments
Labels

Comments

@e-jigsaw
Copy link

Hi,

My project's package.json is

  "config": {
    "DEST": "build",
    "PORT": "3000"
  },
  "scripts": {
    ...
    "build:before": "mkdir -p $npm_package_config_DEST",
    ...
  }

build:before task is just making directory.

$ npm run build:before
...
$ echo $?
0
$ npm-run-all build:before
...
ERROR: build:before: None-Zero Exit(7);
...
npm ERR! node v5.0.0
npm ERR! npm  v3.3.9

v1.2.13 works fine but v1.3.0 has been broken :(

Any suggestions?

Thanks

@misteroneill
Copy link

Confirming that I'm seeing this on any script that uses npm-run-all, but running the scripts individually has no issues.

@alicoding
Copy link

I'm seeing the same problem here. It looks like this happened after the code refractor patch...

@janl
Copy link

janl commented Nov 18, 2015

Seeing this too. Confirmed that it is past 8004ce4 (“Refactoring”).

I’ve traced it down to stdout/err problems. When I added a fs.createWriteableStream() to the options passed to spawn() in spawn-posix.js (e.g. log stdout/err into files). Things work as expected.

Do this in spawn-posix.js if you want to reproduce:

function spawn(command, args, options) {
    var fs = require('fs')
    var ofd = fs.openSync('npm-run-all.stdout', 'w')
    var efd = fs.openSync('npm-run-all.stderr', 'w')
    var out = fs.createWriteStream('', {fd: ofd, flags:'w'});
    var err = fs.createWriteStream('', {fd: efd, flags:'w'});

    options.detached = true; // eslint-disable-line no-param-reassign
    options = {
      stdio: [options.stdio[0], out, err]
    }
    console.log(command, args, options);
    var child = _child_process2["default"].spawn(command, args, options);
    child.on("exit", removeFromPool);
    child.on("error", function(error) {
      console.log(error);
      removeFromPool()
    });
    child.kill = kill;

    // Add to the pool to kill on exit.
    children.push(child);

    return child;
}

Good luck with this one <3

janl added a commit to janl/npm-run-all that referenced this issue Nov 18, 2015
@janl
Copy link

janl commented Nov 18, 2015

And again as a diff, if that’s easier, full commit here: janl@2889479 branch here: https://github.com/janl/npm-run-all/tree/issue/14

diff --git a/src/lib/spawn-posix.js b/src/lib/spawn-posix.js
index c04abc1..8f10254 100644
--- a/src/lib/spawn-posix.js
+++ b/src/lib/spawn-posix.js
@@ -48,8 +48,18 @@ function kill() {
  * @returns {ChildProcess} A ChildProcess instance of new process.
  * @private
  */
+
+var fs = require('fs')
 export default function spawn(command, args, options) {
+    var ofd = fs.openSync('npm-run-all.stdout', 'w')
+    var efd = fs.openSync('npm-run-all.stderr', 'w')
+    var out = fs.createWriteStream('', {fd: ofd});
+    var err = fs.createWriteStream('', {fd: efd});
+
     options.detached = true; // eslint-disable-line no-param-reassign
+    options = {
+      stdio: [options.stdio[0], out, err]
+    }

     const child = cp.spawn(command, args, options);
     child.on("exit", removeFromPool);

@mysticatea
Copy link
Owner

Oh my God, I apologize for it.
For a first aid, I reverted to v1.2.13 and published as v1.3.1.

My bad, I had not been having tests for stdin/stdout, so these were not tested in Travis CI.

@mysticatea
Copy link
Owner

@janl Thank you for investigating.

Hmm, I seem to need changing my strategy that I use process group id to kill child processes.

@mysticatea mysticatea added the bug label Nov 19, 2015
@mysticatea
Copy link
Owner

Hmm, I'm trying to add tests for this bug, but it works in Travis CI...
This might be related with nodejs/node#3596

@e-jigsaw
Copy link
Author

@mysticatea Thanks for great support!

@misteroneill
Copy link

👍

@janl
Copy link

janl commented Nov 24, 2015

nice! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants