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

[v14.x] Backport AbortController and friends #38386

Closed

Commits on Apr 30, 2021

  1. lib: initial experimental AbortController implementation

    AbortController impl based very closely on:
     https://github.com/mysticatea/abort-controller
    
    Marked experimental.
    Not currently used by any of the existing promise apis.
    
    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#33527
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    1cff8fd View commit details
    Browse the repository at this point in the history
  2. timers: allow promisified timeouts/immediates to be canceled

    Using the new experimental AbortController...
    
    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#33833
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Gus Caplan <me@gus.host>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    c86e131 View commit details
    Browse the repository at this point in the history
  3. timers: fix multipleResolves in promisified timeouts/immediates

    After successful timer finish the abort event callback would still
    reject (already resolved promise) upon calling abortController.abort().
    
    Signed-off-by: Denys Otrishko <shishugi@gmail.com>
    
    PR-URL: nodejs#33949
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    lundibundi authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    290ce9f View commit details
    Browse the repository at this point in the history
  4. timers: move promisified timers implementations

    Move the promisified timers implementations into a new internal.
    submodule.
    
    Also adds `ref` option to the promisified versions.
    
    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#33950
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    d097171 View commit details
    Browse the repository at this point in the history
  5. timers: use AbortController with correct name/message

    On the web, `AbortError` is the error name, not the error
    message. Change the code to match that.
    
    PR-URL: nodejs#34763
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    addaleax authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    26b7626 View commit details
    Browse the repository at this point in the history
  6. events: allow use of AbortController with once

    Allows an AbortSignal to be passed in to events.once() to cancel
    waiting on an event.
    
    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#34911
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    268686a View commit details
    Browse the repository at this point in the history
  7. events: allow use of AbortController with on

    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#34912
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    51031f3 View commit details
    Browse the repository at this point in the history
  8. doc: revise AbortSignal text and example using events.once()

    Add a line to the example code to clarify what happens if an event is
    emitted after listening is canceled. Make minor revisions to surrounding
    text.
    
    PR-URL: nodejs#35005
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Trott authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    affb52d View commit details
    Browse the repository at this point in the history
  9. doc: make AbortSignal text consistent in events.md

    Further minor modifications to AbortSignal text in events.md for
    consistency.
    
    PR-URL: nodejs#35005
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Trott authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    561d832 View commit details
    Browse the repository at this point in the history
  10. events: make abort_controller event trusted

    The AbortController abort event is trusted, currently we fire all
    events with isTrusted: false. Allow dispatching events
    internally with `isTrusted: true` and add a test for it.
    
    Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
    Fixes: nodejs#35748
    
    PR-URL: nodejs#35811
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    b389182 View commit details
    Browse the repository at this point in the history
  11. lib: let abort_controller target be EventTarget

    The AbortController abort event should have EventTarget as a target
    property of the argument event.
    
    PR-URL: nodejs#35869
    Refs: https://github.com/web-platform-tests/wpt/blob/master/dom/abort/event.any.js
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    watilde authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    f76ab5a View commit details
    Browse the repository at this point in the history
  12. test: integrate abort_controller tests from wpt

    Refs: web-platform-tests/wpt#9361
    
    PR-URL: nodejs#35869
    Refs: https://github.com/web-platform-tests/wpt/blob/master/dom/abort/event.any.js
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    watilde authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    76cdf87 View commit details
    Browse the repository at this point in the history
  13. fs: add support for AbortSignal in readFile

    PR-URL: nodejs#35911
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    dc3d852 View commit details
    Browse the repository at this point in the history
  14. fs: support abortsignal in writeFile

    PR-URL: nodejs#35993
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    ceef7e3 View commit details
    Browse the repository at this point in the history
  15. events: add a few tests

    PR-URL: nodejs#35806
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    01d2b67 View commit details
    Browse the repository at this point in the history
  16. events: support emit on nodeeventtarget

    PR-URL: nodejs#35851
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
    Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    1ca549d View commit details
    Browse the repository at this point in the history
  17. events: define event handler as enumerable

    PR-URL: nodejs#35931
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    307bebc View commit details
    Browse the repository at this point in the history
  18. events: support event handlers on prototypes

    PR-URL: nodejs#35931
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    902503c View commit details
    Browse the repository at this point in the history
  19. events: define abort on prototype

    PR-URL: nodejs#35931
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    6bbd82f View commit details
    Browse the repository at this point in the history
  20. events: fire handlers in correct oder

    PR-URL: nodejs#35931
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    7d255e6 View commit details
    Browse the repository at this point in the history
  21. events: disabled manual construction AbortSignal

    Fixes: nodejs#36064
    
    PR-URL: nodejs#36094
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Zeyu Yang <himself65@outlook.com>
    Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    RaisinTen authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    0131586 View commit details
    Browse the repository at this point in the history
  22. events: getEventListeners static

    PR-URL: nodejs#35991
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    555a5a2 View commit details
    Browse the repository at this point in the history
  23. http: add support for abortsignal to http.request

    PR-URL: nodejs#36048
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Denys Otrishko <shishugi@gmail.com>
    Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    e8bd59c View commit details
    Browse the repository at this point in the history
  24. http2: add support for AbortSignal to http2Session.request

    - Add support
    - Add test
    - Docs once PR is up
    
    PR-URL: nodejs#36070
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    MadaraUchiha authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    5ce6f91 View commit details
    Browse the repository at this point in the history
  25. child_process: add AbortSignal support

    PR-URL: nodejs#36308
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    8277ec1 View commit details
    Browse the repository at this point in the history
  26. test: increase execFile abort coverage

    Verify that if something different than Abortcontroller.signal is passed
    to child_process.execFile(), ERR_INVALID_ARG_TYPE is thrown.
    
    PR-URL: nodejs#36429
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    shootermv authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    6c86e68 View commit details
    Browse the repository at this point in the history
  27. child_process: clean event listener correctly

    I was working on AbortSignal for spawn and noticed there is a leak in
    the current code for AbortSignal support in child_process since it
    removes the wrong listener. I used the new signal as argument feature
    to make removing the listener easier and added a test.
    
    PR-URL: nodejs#36424
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    4f04104 View commit details
    Browse the repository at this point in the history
  28. child_process: add signal support to spawn

    PR-URL: nodejs#36432
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    44a304d View commit details
    Browse the repository at this point in the history
  29. child_process: support AbortSignal in fork

    PR-URL: nodejs#36603
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    b9732d4 View commit details
    Browse the repository at this point in the history
  30. timers: refactor to use validateAbortSignal

    PR-URL: nodejs#36604
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
    Reviewed-By: Richard Lau <rlau@redhat.com>
    Lxxyx authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    130b797 View commit details
    Browse the repository at this point in the history
  31. dgram: support AbortSignal in createSocket

    PR-URL: nodejs#37026
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Nitzan Uziely authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    1b04e63 View commit details
    Browse the repository at this point in the history
  32. fs: add AbortSignal support to watch

    PR-URL: nodejs#37190
    Refs: nodejs#37179
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Darshan Sen <raisinten@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    ef6af8c View commit details
    Browse the repository at this point in the history
  33. fs: fix pre-aborted writeFile AbortSignal file leak

    Fix an issue in writeFile where a file is opened, and not closed
    if the abort signal is aborted after the file was opened
    but before writing began.
    
    PR-URL: nodejs#37393
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Nitzan Uziely authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    88b3463 View commit details
    Browse the repository at this point in the history
  34. doc: recommend checking abortSignal.aborted first

    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#37714
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
    Reviewed-By: Darshan Sen <raisinten@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    a80d272 View commit details
    Browse the repository at this point in the history
  35. events: add max listener warning for EventTarget

    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#36001
    Fixes: nodejs#35990
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    6b3a21c View commit details
    Browse the repository at this point in the history
  36. lib: set abort-controller toStringTag

    PR-URL: nodejs#36115
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    benjamingr authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    a2cf563 View commit details
    Browse the repository at this point in the history
  37. lib: implement AbortSignal.abort()

    Refs: whatwg/dom#960
    
    PR-URL: nodejs#37693
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    436a2d2 View commit details
    Browse the repository at this point in the history
  38. test: update dom/abort tests

    Signed-off-by: James M Snell <jasnell@gmail.com>
    
    PR-URL: nodejs#37693
    Refs: whatwg/dom#960
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    jasnell authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    63099e1 View commit details
    Browse the repository at this point in the history
  39. lib: add brand checks to AbortController and AbortSignal

    PR-URL: nodejs#37720
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    MattiasBuelens authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    10131cd View commit details
    Browse the repository at this point in the history
  40. test: fix unreliable test-fs-write-file.js

    The test uses a file name twice, causing unreliability in CI. In
    particular, it's failing a lot on the Raspberry Pi devices.
    
    Fixes: nodejs#36090
    
    PR-URL: nodejs#36102
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Richard Lau <rlau@redhat.com>
    Trott authored and targos committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    9abc11a View commit details
    Browse the repository at this point in the history