sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API
MIT License
11.91k stars 342 forks source link

TypeError: The "emitter" argument must be an instance of EventEmitter or EventTarget. Received an instance of AbortSignal #498

Closed himself65 closed 3 weeks ago

himself65 commented 1 year ago
TypeError: The "emitter" argument must be an instance of EventEmitter or EventTarget. Received an instance of AbortSignal
    at new NodeError (node:internal/errors:399:5)
    at getEventListeners (node:events:914:9)
    at new Request (node:internal/deps/undici/undici:7138:17)
    at new Ky (file:///Users/himself65/Code/AFFiNE/node_modules/ky/source/core/Ky.ts:178:18)
    at Function.create (file:///Users/himself65/Code/AFFiNE/node_modules/ky/source/core/Ky.ts:24:14)
    at Function.ky.<computed> [as post] 

Upstream: https://github.com/nodejs/undici/pull/1910

belden commented 11 months ago

@himself65 / @sindresorhus this was the first search result for an error I saw when upgrading my application (which does not use this project) from node-16 to node-18.

I see that this project tries to use node-14, and I wonder whether @himself65 was using this with node >= 18 when encoutering this issue.

I don't have a solution for my upgrade yet but wanted to share what I know so far.

Update, the solution in my case was to stop importing abort-controller from npm and use the built-in that I get as part of upgrading node-16 -> node-18.

himself65 commented 11 months ago

I think this is a bug in the old nodejs 18 version, now it seems to be fixed

himself65 commented 11 months ago

Solution https://github.com/nodejs/undici/pull/1910#issuecomment-1500332168

sholladay commented 3 weeks ago

Closing due to upstream fixes.