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

feat(process) support AbortSignal in run #11579

Closed
wants to merge 3 commits into from

Conversation

benjamingr
Copy link
Contributor

Support AbortSignal in Deno.run

This continues the work in #10943 and adds AbortSignal support to Deno.run. Closes #11574

cc @lucacasonato @bartlomieju

Comment on lines +125 to +127
const stopper = () => {
p.kill(Deno.Signal.SIGTERM);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Process.kill is an unstable API (https://doc.deno.land/builtin/unstable#Deno.kill) so we can't add it like this to stable Deno.run. Also I'm a bit worried about bifurcation that sending SIGTERM could be done with two different APIs.

We need to discuss this change more in-depth before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartlomieju that is acceptable to me, I am in no rush to make these changes. The idea is to add a web-standard-capability way to cancel operations so that you use Deno APIs and web APIs similarly and can abort your sub-process, event handlers and fetch with the same AbortSignal.

I am happy to be part of that discussion though I am also fine with you having this discussion without me and just letting me know.

Note that adding this API to Node.js involved some discussion - the major points are:

  • Would users be confused by the parameter being called signal since in non-web-standards land signal means something else for processes? (Node decided to prefer web-standards)
  • Would users be confused by this sending a signal to the process? Which signal should it send? (In node that is configurable as killSignal and whatever stops the process elsewhere works here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also the technical limitation (process.kill being unstable) seems like the smaller concern here and what API users should get seems like the much bigger one. I am happy to refactor this PR to use whatever machinary .kill is using directly in order to bypass the unstability of .kill it's not a big deal)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamingr sorry for late reply, I missed your comments.

that is acceptable to me, I am in no rush to make these changes. The idea is to add a web-standard-capability way to cancel operations so that you use Deno APIs and web APIs similarly and can abort your sub-process, event handlers and fetch with the same AbortSignal.

This is a good argument.

I agree that signal might be a confusing name, my first thought when I saw it was OS signal - let's bikeshed on this.

(Also the technical limitation (process.kill being unstable) seems like the smaller concern here and what API users should get seems like the much bigger one. I am happy to refactor this PR to use whatever machinary .kill is using directly in order to bypass the unstability of .kill it's not a big deal)

Actually looking at it I don't think there are any blockers to stabilize this API so that would allows us to move forward with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with the name signal is that the web standards require:

Any web platform API using promises to represent operations that can be aborted must adhere to the following:

 - Accept AbortSignal objects through a signal dictionary member.
 - Convey that the operation got aborted by rejecting the promise with an "AbortError" DOMException.
 - Reject immediately if the AbortSignal's aborted flag is already set, otherwise:
 - Use the abort algorithms mechanism to observe changes to the AbortSignal object and do so in a manner that does not lead to clashes with other observers.

Note that this isn't actually a web API so Deno doesn't have to use the same web standard conventions but it is probably preferable to do so if web-familiarity and compatibility is a goal. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'm not sure, it's quite confusing, I will confer with other team members on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let me know :)

@bartlomieju bartlomieju added this to the 1.15.0 milestone Sep 13, 2021
@crowlKats
Copy link
Member

It might make more sense to not add any new features to Deno.run since there is the plan to soon deprecate it with the new subprocess API, and just directly implement it there

@sant123
Copy link

sant123 commented Oct 4, 2021

See #11016

@crowlKats
Copy link
Member

And #11618

@lucacasonato lucacasonato removed this from the 1.15.0 milestone Oct 11, 2021
@CLAassistant
Copy link

CLAassistant commented Oct 15, 2021

CLA assistant check
All committers have signed the CLA.

@benjamingr
Copy link
Contributor Author

I think the CLA bot is broken?

@bartlomieju
Copy link
Member

I think the CLA bot is broken?

Ryan changed email assigned to CLA bot so it's requesting signing from everyone again 😅

@stale
Copy link

stale bot commented Dec 14, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

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

Successfully merging this pull request may close these issues.

[Feature request]: support AbortSignal for subprocess
6 participants