concurrently: How to ignore exit code 1 when a process is killed ?

In package.json I’ve the following line with the purpose to:

  • start testrpc-sc
  • run coverage
  • when coverage is done -> kill the testrpc-sc process
"coverage": "concurrently -k \"node_modules\\.bin\\testrpc-sc --port 8555\" \"node_modules\\.bin\\solidity-coverage\"",

However my npm command fails because testrpc-sc is killed and returns a exit 1.

See logging:

[1] Istanbul coverage reports generated [1] Cleaning up… [1] node_modules.bin\solidity-coverage exited with code 0 –> Sending SIGTERM to other processes… [0] node_modules.bin\testrpc-sc --port 8555 exited with code 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! supplychainlog@1.0.0 coverage: concurrently --kill-others "node_modules\.bin\testrpc-sc --port 8555" "node_modules\.bin\solidity-coverage" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the supplychainlog@1.0.0 coverage script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

How to let npm know that a Exit status 1 is ok ?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Use concurrently --success first, this will make only the exit status of coverage (first child that exited) matter. I’m am running e2e tests, || true solution does not work because it hides all errors.

I can also confirm that using --success last didn’t work for me but switching the order and using --success first did.

This is the command that wasn’t working (always non-zero exit despite using --success last, I speculate the exit code is from --kill-others killing the first command):

concurrently --success last --kill-others  --no-color --raw  "npm run test:e2e-serve" "wait-on http-get://localhost:4200 && npm run cypress:cl"

This one works and gives me the exit code from npm run cypress:cl:

concurrently --success first --kill-others  --no-color --raw  "wait-on http-get://localhost:4200 && npm run cypress:cl" "npm run test:e2e-serve" 

Strangely --success first works while --success last does not.

I still see same issue

[1] [19:02:19] I/launcher - 0 instance(s) of WebDriver still running
[1] [19:02:19] I/launcher - chrome #01 passed
[1] [19:02:19] I/launcher - firefox #11 passed
[1] Closing report
[1] ng e2e front-e2e exited with code 0
--> Sending SIGTERM to other processes..
[0] npm run start-mock-api exited with code SIGTERM
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.0.0 e2e-ci-updated: `concurrently --kill-others --success first "npm run start-mock-api" "ng e2e front-e2e"`
npm ERR! Exit status 1
npm ERR! 

I am trying to run two scripts at once with concurrently. The basic command looks something like this:

concurrently -k --success first "node ./tools/mock-webapi/mock-webapi.js" "npm run test-single-run"

Which in turn calls (local):

"test-single-run": "karma start --single-run --browsers ChromeHeadless"

Or on remote (teamcity host):

"test-teamcity": "karma start --reporters teamcity --single-run --browsers ChromeHeadless",

The tests run just fine (local & remote). However, I keep getting exit code 1. Even if I use concurrently -k --success first I still get a code 1 even with --success first.

[1] 09 05 2018 17:56:54.032:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
[1] npm run test-single-run exited with code 0
--> Sending SIGTERM to other processes..
[0] node ./tools/mock-webapi/mock-webapi.js exited with code 1

I tried various ways for json-server to gracefully receive this signal. Nothing seems to work.

mock-webapi.js

process.on('SIGTERM', function (code) {
    console.log('Handle SIGTERM', process.pid, code);
    exitCode = 0;
    server.close(function () {
        process.exit(0);
    });
});

process.on('SIGKILL', function (code) {
    console.log('SIGKILL received...', code);
    exitCode = 0;
    server.close(function () {
        process.exit(0);
    });
});

process.on('SIGINT', function (code) {
    console.log('SIGINT received...', code);
    exitCode = 0;
    server.close(function () {
        process.exit(0);
    });
});

I found a workable solution here: https://stackoverflow.com/questions/26814034/silencing-errors-on-failures-for-npm-run-script

My solution is:

And full command is now:

"coverage": "concurrently --names \"TestRPC,Coverage\" --kill-others \"node_modules\\.bin\\testrpc-sc --port 8555\" \"node_modules\\.bin\\solidity-coverage\" || true",