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
$ node
Welcome to Node.js v18.13.0.
Type ".help" for more information.
> const { fetch } = require('undici');
undefined
> await fetch("https://bing.com/translator", { headers: { host: 'bing.com' } });
Uncaught TypeError: fetch failed
at fetch ($PWD/node_modules/undici/index.js:110:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async REPL2:1:33 {
cause: Error: Client network socket disconnected before secure TLS connection was established
at connResetException (node:internal/errors:718:14)
at TLSSocket.onConnectEnd (node:_tls_wrap:1600:19)
at TLSSocket.emit (node:events:525:35)
at TLSSocket.emit (node:domain:552:15)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET',
path: undefined,
host: 'www.bing.com',
port: 443,
localAddress: null
}
}
> await fetch("https://bing.com/translator");
Response {
[Symbol(realm)]: null,
[ .. all good without explicit host: .. ]
The bug happens with bing.com because it tries to redirect to www.bing.com; it doesn't happen for domains that don't redirect, such as fanyi.baidu.com.
Reproducible By
The bug happens with bing.com because it tries to redirect to www.bing.com; it doesn't happen for domains that don't redirect, such as fanyi.baidu.com.
Environment