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

Allow aborting shell commands #461

Open
pimterry opened this issue Jun 15, 2023 · 0 comments
Open

Allow aborting shell commands #461

pimterry opened this issue Jun 15, 2023 · 0 comments

Comments

@pimterry
Copy link

Would you be open to adding abort support to shell commands?

I have some commands that occasionally get stuck, and it would be useful to be able to cancel them entirely to kill them (by closing the underlying connection, which does seem to kill the running command). I think the standard AbortController would be a good way to do this, I'm imagining an API like:

const controller = new AbortController();
const signal = controller.signal;

adbClient.shell(command, { signal });

// Later, to abort:
controller.abort(); // .destroy() on the underlying TCP connection

This matches the abort behaviour in lots of other JS APIs, e.g. fetch: https://developer.mozilla.org/en-US/docs/Web/API/AbortController#examples.

AbortController is available as a global in v14.17+, so all current Node versions. I can see that in theory this package supports back to Node 0.10, but I think this would be implementable so that it doesn't break anything in older versions, and it's just if you wanted to use this specific feature in older Node you'd need to bring a polyfill.

Would that work for you? I'd be happy to open a PR for this if it's something you'd be interested in.

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