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

--kill-others --kill-signal=SIGINT exits process with code 1 #521

Open
dankerk opened this issue Dec 16, 2024 · 1 comment
Open

--kill-others --kill-signal=SIGINT exits process with code 1 #521

dankerk opened this issue Dec 16, 2024 · 1 comment

Comments

@dankerk
Copy link

dankerk commented Dec 16, 2024

I don't know if this is a bug or a feature request or if I'm simply not understanding how to properly use this package.

  • Description:
    I'm trying to run a web server, then run some e2e tests. When the tests complete successfully, the web server process is ended with SIGTERM, causing NPM to think the tests failed.
    If I don't kill the web server, the task keeps running forever/times out.

I've tried concurrently --kill-others --kill-signal=SIGINT "start server" && "run e2e tests"
as well as concurrently --kill-others --success last "start server" && "run e2e tests"

  • Expected Behaviour:
    Processes exit with code 0, NPM thinks (rightfully) that tests pass.

  • Environment:
    In an Azure devOps pipeline running Linux 5.15.0-1074-azure,
    v18.20.5,
    Concurrently 9.1.0

  • Reproduction: A way to reproduce the issue
    concurrently --kill-others --kill-signal=SIGINT "start server" && "run e2e tests"
    or concurrently --kill-others --success last "start server" && "run e2e tests"

Would you be able to see whether I'm doing something wrong if this is a feature request or bug?
Many thanks.

Screenshot 2024-12-16 at 18 38 17

@dankerk
Copy link
Author

dankerk commented Dec 16, 2024

I started fresh today and decided to give it one another crack. As it turns out I didn't configure the command properly.

I should have used --success first instead of --success last.

For anyone facing a similar problem (I think I saw one or two similar issues), consider this:

"your-concurrently-script.js":

const concurrently = require('concurrently');

/** Start dev server */
const startDevServer = 'nx run your-project:serve:development';

/** Wait until dev server is ready, then start running e2e tests */
const startE2eTests = 'wait-on https://localhost:4200 && nx run your-project-e2e:playwright:e2e';

const commands = [startDevServer, startE2eTests];

/** Consider NPM task successful after the first process that exits, exits. Kill other processes when the first command fails or the second command succeeds */
const options = { successCondition: 'first', killOthers: ['failure', 'success'] };

const { result } = concurrently(commands, options);
result.then(
	() => {
		console.log('Successfully ran e2e tests');
	},
	() => {
		console.log('Failed to run e2e tests');
	}
);

In your package.json:

...
"concurrently-fun": "node your-concurrently-script.js"
...
}```

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

No branches or pull requests

1 participant