-
-
Notifications
You must be signed in to change notification settings - Fork 689
Closed
Labels
DocsChanges related to the documentationChanges related to the documentation
Description
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, undici@6.6.2
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
Metadata
Metadata
Assignees
Labels
DocsChanges related to the documentationChanges related to the documentation