Intent to Prototype and Ship: AbortSignal.abort() static method

157 views
Skip to first unread message

Timothy Gu

unread,
Jun 3, 2021, 5:56:28 PM6/3/21
to blink-dev

Contact emails
timo...@chromium.org

Explainer
https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort

Specification
https://dom.spec.whatwg.org/#dom-abortsignal-abort

API spec
Yes

Summary
AbortSignal.abort() is a static method that allows creating a new AbortSignal object that is already aborted. It is similar in spirit to Promise.reject(), and provides improved developer ergonomics.

Blink component
Blink>DOM

Motivation
Web developers have found aborted AbortSignal objects to be useful for a variety of purposes. It signifies to JavaScript APIs that no work should be done. However currently, creating an already-aborted AbortSignal object requires jumping through quite a few hoops:

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

A new AbortSignal.abort() factory function simplifies this to just

return AbortSignal.abort();

Initial public proposal
https://github.com/whatwg/dom/issues/959

Search tags
AbortSignal

TAG review
This is a minor change that does not change the overall shape of the AbortController/AbortSignal API. Furthermore, it is trivially polyfillable, and has already been shipped in both Firefox and Safari Technical Preview.

TAG review status
Not applicable

Risks

Interoperability and Compatibility
Gecko: Shipped/Shipping (https://bugzilla.mozilla.org/show_bug.cgi?id=1698468)
WebKit: Shipped/Shipping (https://bugs.webkit.org/show_bug.cgi?id=223071)
Web developers: Positive (https://github.com/whatwg/dom/issues/959)

Is this feature fully tested by web-platform-tests?
Yes

Flag name
N/A

Tracking bug
https://bugs.chromium.org/p/chromium/issues/detail?id=1187117

Measurement
Will be measured by the V8AbortSignal_Abort_Method UseCounter once implemented.

Link to entry on the Chrome Platform Status
https://www.chromestatus.com/feature/5642501387976704

This intent message was generated by Chrome Platform Status.

Manuel Rego Casasnovas

unread,
Jun 4, 2021, 3:08:40 AM6/4/21
to Timothy Gu, blink-dev
LGTM1, it's nice to catch up with other browsers.

On 03/06/2021 23:30, Timothy Gu wrote:
>
> *Contact emails
> *timo...@chromium.org <mailto:timo...@chromium.org>
>
>
> *Explainer
> *https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort
> <https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort>
>
>
> *Specification
> *https://dom.spec.whatwg.org/#dom-abortsignal-abort
> <https://dom.spec.whatwg.org/#dom-abortsignal-abort>
>
>
> *API spec
> *Yes
>
>
> *Summary
> *AbortSignal.abort() is a static method that allows creating a
> new AbortSignal object that is already aborted. It is similar in
> spirit to Promise.reject(), and provides improved developer
> ergonomics.
>
>
> *Blink component
> *Blink>DOM
> <https://bugs.chromium.org/p/chromium/issues/list?q=component:Blink%3EDOM>
>
>
> *Motivation
> *Web developers have found aborted AbortSignal objects to be
> useful for a variety of purposes. It signifies to JavaScript
> APIs that no work should be done. However currently, creating an
> already-aborted AbortSignal object requires jumping through
> quite a few hoops:
>
> const controller = new AbortController();
> controller.abort();
> return controller.signal;
>
>
> A new AbortSignal.abort() factory function simplifies this to just
>
>
> return AbortSignal.abort();
>
>
> *Initial public proposal
> *https://github.com/whatwg/dom/issues/959
> <https://github.com/whatwg/dom/issues/959>
>
>
> *Search tags
> *AbortSignal
> <https://www.chromestatus.com/features#tags:AbortSignal>
>
>
> *TAG review
> *This is a minor change that does not change the overall shape
> of the AbortController/AbortSignal API. Furthermore, it is
> trivially polyfillable, and has already been shipped in both
> Firefox and Safari Technical Preview.
>
>
> *TAG review status
> *Not applicable
>
>
> *Risks*
>
>
> _*Interoperability and Compatibility*_
>
>
> /_Gecko_/: Shipped/Shipping
> (https://bugzilla.mozilla.org/show_bug.cgi?id=1698468
> <https://bugzilla.mozilla.org/show_bug.cgi?id=1698468>)
>
>
> /_WebKit_/: Shipped/Shipping
> (https://bugs.webkit.org/show_bug.cgi?id=223071
> <https://bugs.webkit.org/show_bug.cgi?id=223071>)
>
>
> /_Web developers_/: Positive
> (https://github.com/whatwg/dom/issues/959
> <https://github.com/whatwg/dom/issues/959>)
>
>
> *Is this feature fully tested by **web-platform-tests*
> <https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md>*?
> *Yes
>
>
> *Flag name
> *N/A
>
>
> *Tracking bug
> *https://bugs.chromium.org/p/chromium/issues/detail?id=1187117
> <https://bugs.chromium.org/p/chromium/issues/detail?id=1187117>
>
>
> *Measurement
> *Will be measured by the V8AbortSignal_Abort_Method UseCounter
> once implemented.
>
>
> *Link to entry on the Chrome Platform Status
> *https://www.chromestatus.com/feature/5642501387976704
> <https://www.chromestatus.com/feature/5642501387976704>
>
> This intent message was generated by Chrome Platform Status
> <https://www.chromestatus.com/>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blink-dev+...@chromium.org
> <mailto:blink-dev+...@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAHp9HL7U2pQh%3D2uhCo6wW3WL_tc0GqbfA%3Dzt3vYb4DF0O4AuEA%40mail.gmail.com
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAHp9HL7U2pQh%3D2uhCo6wW3WL_tc0GqbfA%3Dzt3vYb4DF0O4AuEA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Mike West

unread,
Jun 7, 2021, 8:13:42 AM6/7/21
to Manuel Rego Casasnovas, Timothy Gu, blink-dev
LGTM2.

I agree that we don't need a TAG review here, as we're catching up with other vendors' implementations. 

That said, I only see one test explicitly exercising `AbortSignal.abort()`: https://wpt.fyi/results/dom/abort/event.any.html?label=master&label=experimental&aligned. It's pretty simple, but is it that simple? Are there corner cases we might be missing?

-mike


To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/a94ad2d8-a153-8d11-0449-591a51709c54%40igalia.com.

Yoav Weiss

unread,
Jun 7, 2021, 9:12:23 AM6/7/21
to Mike West, Manuel Rego Casasnovas, Timothy Gu, blink-dev
LGTM3 while echoing Mike's testing question.

Timothy Gu

unread,
Jun 7, 2021, 2:41:50 PM6/7/21
to Mike West, Manuel Rego Casasnovas, blink-dev
Hi everyone,

Thanks for the LGTMs!

On Mon, Jun 7, 2021 at 5:13 AM Mike West <mk...@chromium.org> wrote:
That said, I only see one test explicitly exercising `AbortSignal.abort()`: https://wpt.fyi/results/dom/abort/event.any.html?label=master&label=experimental&aligned. It's pretty simple, but is it that simple? Are there corner cases we might be missing?

Thanks a lot for the feedback. I can definitely think of additional things to test, and I'll keep that in mind as I begin implementing the feature.

[...]

Best,
Timothy
Reply all
Reply to author
Forward
0 new messages