Bug Description
Checking the string uri in the ProxyAgent class does not work consistently. It may consider some non-existent IP addresses valid and sometimes not valid. In addition, in some cases it can change the IP address that was transmitted via string uri to ProxyAgent.
Reproducible By
'use strict';
const { fetch, ProxyAgent } = require('undici');
const URL = 'https://google.com';
const proxyUri1 = 'http://123.123.0123.123:8080'; // Valid for ProxyAgent
const proxyUri2 = 'http://0123.123.123.123:8080'; // Valid too
const proxyUri3 = 'http://085.26.146.169:8080'; // Invalid
const proxyUri4 = 'http://85.026.0146.169:8080'; // Valid too but convert ip to 85.22.102.169 ??
const proxyAgent = new ProxyAgent(proxyUri4);
(async () => {
const res = await fetch(URL, { dispatcher: proxyAgent });
console.log(await res.text());
})();
Environment
macOS Sonoma 14.3.1, Node.js v20.11.0, [email protected]
Additional
Example of error output using proxyUri3 variable
node:internal/url:775
this.#updateContext(bindingUrl.parse(input, base));
^
TypeError: Invalid URL
at new URL (node:internal/url:775:36)
at new ProxyAgent (/Users/timursevimli/Programming/Projects/deneme/node_modules/undici/lib/proxy-agent.js:68:25)
at Object.<anonymous> (/Users/timursevimli/Programming/Projects/deneme/issue.js:12:20)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 'ERR_INVALID_URL',
input: 'http://085.26.146.169:8080'
}
Node.js v20.11.0
Example of error output using proxyUri4 variable
/Users/timursevimli/Programming/Projects/deneme/node_modules/undici/index.js:103
Error.captureStackTrace(err, this)
^
TypeError: fetch failed
at fetch (/Users/timursevimli/Programming/Projects/deneme/node_modules/undici/index.js:103:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/timursevimli/Programming/Projects/deneme/issue.js:15:15 {
[cause]: Error: connect ECONNREFUSED 85.22.102.169:8080
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '85.22.102.169',
port: 8080
}
}
Node.js v20.11.0
Bug Description
Checking the string uri in the ProxyAgent class does not work consistently. It may consider some non-existent IP addresses valid and sometimes not valid. In addition, in some cases it can change the IP address that was transmitted via string uri to ProxyAgent.
Reproducible By
Environment
macOS Sonoma 14.3.1, Node.js v20.11.0, [email protected]
Additional
Example of error output using
proxyUri3variableExample of error output using
proxyUri4variable