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

killOthers won't fully terminate others if also restartTries >= 1 #496

Open
sod opened this issue Aug 5, 2024 · 2 comments
Open

killOthers won't fully terminate others if also restartTries >= 1 #496

sod opened this issue Aug 5, 2024 · 2 comments

Comments

@sod
Copy link

sod commented Aug 5, 2024

If you use concurrently like:

node_modules/.bin/concurrently 'node foo.js 0' 'node foo.js 1' --kill-others --restart-tries 2
// foo.js - test script, `node foo.js 0` dies after 100ms, `node foo.js 1` stays alive
const id = process.argv[2];
console.log(`Hello world from id ${id}`);
if (id === '0') { setTimeout(() => { process.exit(1) }, 100) /* kill id 0 */ }
else { setTimeout(() => {}, 99999999) /* keep id 1 alive */ }

What happens:

It restarts process 0 twice, then runs the kill-others command. But the kill other is catched by another retry.

CleanShot 2024-08-05 at 14 20 10@2x

What I expected

if restart-tries has been exhausted, then kill-others should tear down the rest for good.

@gustavohenke
Copy link
Member

Hey. This is how concurrently has always worked.

I think we can add a new flag/flag value to skip restarting other commands, if any of them has exhausted their restarts.
Might be a bit counter intuitive, but I was thinking of something like --kill-others skip-restarts or --kill-others immediately - but I'm not very comfortable with either yet.
Let me know if you got better ideas 😅

This should be reasonably easy to implement if you'd like to take a stab at it; I imagine it might be a simple takeUntil or takeWhile operator here:

failure.pipe(
delayOperator,

@sod
Copy link
Author

sod commented Aug 15, 2024

I'd file this under wrong behavior (as it kills and restarts the other one). But I fully understand that maintaining a popular library has to take into account that people now may rely on this behavior.

With that in mind, I'd implement the API like:

node_modules/.bin/concurrently \
    'node foo.js 0' \
    'node foo.js 1' \
    --kill-others \
    --total-restart-tries 2
#   ^^^^^^^^^^^^^^^^^^^^^^^^ a new setting

With:

--restart-tries 2 # default and old behavior - every command has its individual retry counter
--total-restart-tries 2 # new behavior - every command reduces a single counter - if that is exhausted, no further retries are being done

With this API, the new option also has a purpose on its own and isn't just there to workaround for --kill-others.

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

No branches or pull requests

2 participants