Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: fetch failed. node:internal/deps/undici/undici:12345:11 #2964

Open
yqz945 opened this issue Mar 15, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@yqz945
Copy link

yqz945 commented Mar 15, 2024

Bug Description

node fetch can't not connect openai api endpoint.
The following error occurred, and I think it's ok about one month ago.
Uncaught TypeError: fetch failed
at node:internal/deps/undici/undici:12345:11
node v18.*, v20.11.1

Reproducible By

PS C:\Users\Lenovo\Desktop> node
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> await fetch('https://api.openai.com/v1/chat/completions')
Uncaught TypeError: fetch failed
    at node:internal/deps/undici/undici:12345:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async REPL1:1:33 {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:7492:28)
      at node:internal/deps/undici/undici:7448:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:7478:37)
      at process.processImmediate (node:internal/timers:478:21)
      at process.topLevelDomainCallback (node:domain:160:15)
      at process.callbackTrampoline (node:internal/async_hooks:128:24) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}

Expected Behavior

The openai http api can be invoked normally

Logs & Screenshots

Uncaught TypeError: fetch failed
at node:internal/deps/undici/undici:12345:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async REPL1:1:33 {
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:7492:28)
at node:internal/deps/undici/undici:7448:50
at Immediate._onImmediate (node:internal/deps/undici/undici:7478:37)
at process.processImmediate (node:internal/timers:478:21)
at process.topLevelDomainCallback (node:domain:160:15)
at process.callbackTrampoline (node:internal/async_hooks:128:24) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}

Environment

nodejs version is : 20.11.1
os is: Microsoft Windows NT 10.0.22631.0 (Win11)

Additional context

I thought it's not a network issue. The browser is ok, and openai python sdk woks fine at the same time.
google has same problem.

PS C:\Users\Lenovo\Desktop> node .\test.js
URL: https://www.google.com
node:internal/deps/undici/undici:12345
    Error.captureStackTrace(err, this);
          ^

TypeError: fetch failed
    at node:internal/deps/undici/undici:12345:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (C:\Users\Lenovo\Desktop\test.js:3:15) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:7492:28)
      at node:internal/deps/undici/undici:7448:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:7478:37)
      at process.processImmediate (node:internal/timers:478:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}

Node.js v20.11.1

Github is ok.

PS C:\Users\Lenovo\Desktop> node .\test.js
URL: https://www.github.com
200
@yqz945 yqz945 added the bug Something isn't working label Mar 15, 2024
@mcollina
Copy link
Member

@ShogunPanda this might be due to happy eyeballs and some IPv6 misconfig on the network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants