Skip to content

Allow aborting shell commands #461

@pimterry

Description

@pimterry

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions