Skip to content

Conversation

@worr
Copy link
Contributor

@worr worr commented Oct 28, 2020

Node has added its own AbortController in 15.0.0. The AbortController signal
inherits from EventTarget. This changes the check to also accept signals of
type EventTarget.

https://nodejs.org/docs/latest-v15.x/api/globals.html#globals_class_abortsignal

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (provide an overview)

Modified the isAbortSignal check to accept EventTarget as well.

Which issue (if any) does this pull request address?

Incompatibility with the new node AbortController

Node has added its own AbortController in 15.0.0. The AbortController signal
inherits from EventTarget. This changes the check to also accept signals of
type EventTarget.

https://nodejs.org/docs/latest-v15.x/api/globals.html#globals_class_abortsignal
@jimmywarting
Copy link
Collaborator

jimmywarting commented Oct 28, 2020

Node has added its own AbortController in 15.0.0.

Cool - have looked forward for this! More spec'ed browser apis!

The AbortController signal inherits from EventTarget.

Cool - Now we also got a spec'ed EventTarget also :)

worr added a commit to worr/node-imdb-api that referenced this pull request Nov 4, 2020
worr added a commit to worr/node-imdb-api that referenced this pull request Nov 4, 2020
@Richienb Richienb changed the title Fix compatibility for node 15.x Support EventTarget as a signal Dec 30, 2020
@Richienb Richienb changed the title Support EventTarget as a signal Support instances of EventTarget as a signal Dec 30, 2020
@Richienb Richienb merged commit 1f4f85e into node-fetch:master Jan 1, 2021
object[NAME] === 'AbortSignal'
typeof object === 'object' && (
object[NAME] === 'AbortSignal' ||
object[NAME] === 'EventTarget'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand this. On Node.js v15.3.0, I see

> new AbortController().signal[Symbol.toStringTag]
'AbortSignal'

So it seems like a bug to accept non-AbortSignal EventTarget objects.

Copy link
Member

Choose a reason for hiding this comment

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

// @worr

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just notice this. yea, it's weird that we check for the name EventTarget. a proper test was not even created... still using the polyfill for this...

node v12 goes EOL soon, so we are thinking of dropping support for node below v14.17 so that we can start using AbortController/AbortSignal provided by NodeJS so that we can pass this signal directly to node's own http.request.

Will create an issue for this. (targeted for v4)

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

Successfully merging this pull request may close these issues.

6 participants