You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the project uses webpack since node: prefix of esm import, used by node-fetch, is not supported by Electron renderer.
Expected behavior
done alert is shown.
Actual behavior
TypeError: The "listener" argument must be of type function. Received an instance of Object
at __node_internal_captureLargerStackTrace (node:internal/errors:463)
at new NodeError (node:internal/errors:370)
at __node_internal_ (node:internal/validators:229)
at checkListener (node:events:131)
at ClientRequest.once (node:events:533)
at new ClientRequest (node:_http_client:209)
at request (node:http:96)
at renderer.js:111
at new Promise (<anonymous>)
at fetch (renderer.js:66)
at renderer.js:7025
at renderer.js:7030
at renderer.js:7032
Your Environment
software
version
node-fetch
3.1.0
node
16.13.0 (Electron 15 uses Node 16.5)
npm
7.20.6
Operating System
Windows 10 x64
Additional context
The issue does not occur on node-fetch@3.0.0. Thus it seems a recent regression.
We're facing a similar issue when using node-fetch in a jest test suite with the jsdom environment, since new URL will refer to jsdom's URL, not node's.
Reproduction
Steps to reproduce the behavior:
I've created a sample project: https://github.com/babatakao/node-fetch-3-electron-test . With this sample,
npm ci
npm run build
npm start
Note that the project uses webpack since
node:
prefix of esm import, used by node-fetch, is not supported by Electron renderer.Expected behavior
done
alert is shown.Actual behavior
Your Environment
Additional context
The issue does not occur on node-fetch@3.0.0. Thus it seems a recent regression.
I've found the root cause. At here,
new URL
constructor references NodeJS URL in most cases. However, it references Chromium renderer native URL in the Electron renderer process. This causes type mismatch: NodeJS http library checks that whether the URL hassearchParamsSymbol
or not at https://github.com/nodejs/node/blob/v16.13.0/lib/_http_client.js#L117.I suspect that this should be
import {URL, format as formatUrl} from 'node:url';
🤔The text was updated successfully, but these errors were encountered: