-
-
Notifications
You must be signed in to change notification settings - Fork 715
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
Since undici@6.13.0, undici.fetch breaks on Node.js 18.13.0 and earlier.
"package.json" includes:
"engines": {
"node": ">=18.0"
},
but I'm not sure if anything less than v18.17.0 is really supported anymore -- the move to borp as part of #2267 means that the test suite cannot be run with Node.js earlier than v18.17.0.
Reproducible By
Using this "playfetch.js":
% cat playfetch.js
const undici = require('./');
async function main() {
const res = await undici.fetch('http://www.google.com/');
console.log('res:', res.status);
const text = await res.text();
console.log('text: %s...', text.slice(0, 70));
}
main();In a git clone at commit 8a07bbd (from #3095):
% git remote -v
origin git@github.com:nodejs/undici.git (fetch)
origin git@github.com:nodejs/undici.git (push)
% git log1 -1
* 8a07bbd7 - (HEAD) fetch: avoid creation of an intermediary ReadableStream (#3095) (4 days ago) <Khafra>
% node --version
v18.13.0
% node playfetch.js
res: 200
/Users/trentm/src/undici/lib/web/fetch/index.js:2034
fetchParams.controller.controller.error(new TypeError('terminated', {
^
TypeError: terminated
at Fetch.onAborted (/Users/trentm/src/undici/lib/web/fetch/index.js:2034:49)
at Fetch.emit (node:events:513:28)
at Fetch.terminate (/Users/trentm/src/undici/lib/web/fetch/index.js:93:10)
at /Users/trentm/src/undici/lib/web/fetch/index.js:506:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of ReadableStream
at new NodeError (node:internal/errors:400:5)
at eos (node:internal/streams/end-of-stream:66:11)
at fetchFinale (/Users/trentm/src/undici/lib/web/fetch/index.js:1093:5)
at mainFetch (/Users/trentm/src/undici/lib/web/fetch/index.js:760:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
}
Node.js v18.13.0
This passes in newer Node.js versions.
This passes in earlier undici commits.
Expected Behavior
That "playfetch.js" show work, e.g. with more recent Node v18:
% node --version
v18.20.1
% node playfetch.js
res: 200
text: <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage"...
Environment
Tested on macOS 14.4.1, x86_64.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working