-
A simple reproduction: https://stackblitz.com/edit/stackblitz-starters-1b5vdt?file=index.js I tested it also with the following combinations: It seems unrelated to the side effects of importing, so I have no idea what's causing this. |
Beta Was this translation helpful? Give feedback.
Answered by
mcollina
Jul 2, 2024
Replies: 1 comment 5 replies
-
I'm getting this error: // run `node a.js` in the terminal
const undici = require('./index.js');
// using only one of the two will result an error
const fetch = undici.fetch;
// const Request = undici.Request;
console.log(`Node.js version: ${process.versions.node}`);
console.log(`Built-in Undici version: ${process.versions.undici}`);
fetch(new Request('https://httpbin.org/robots.txt')); node a.js
Node.js version: 20.15.0
Built-in Undici version: 6.13.0
/Users/matteo/Repositories/undici/index.js:112
Error.captureStackTrace(err)
^
TypeError: Failed to parse URL from [object Request]
at fetch (/Users/matteo/Repositories/undici/index.js:112:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError: Invalid URL
at new URL (node:internal/url:797:36)
at new Request (/Users/matteo/Repositories/undici/lib/web/fetch/request.js:115:21)
at fetch (/Users/matteo/Repositories/undici/lib/web/fetch/index.js:140:21)
at fetch (/Users/matteo/Repositories/undici/index.js:109:18)
at Object.<anonymous> (/Users/matteo/Repositories/undici/a.js:12:1)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {
code: 'ERR_INVALID_URL',
input: '[object Request]'
}
}
Node.js v20.15.0 Is this what you are seeing? I think we can do a better error message. TBH, this is expected and I'm not sure we can really change this. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because the two classes are different.