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

fetch openai api error: node:internal/deps/undici/undici:12345 #52091

Closed
yqz945 opened this issue Mar 15, 2024 · 2 comments
Closed

fetch openai api error: node:internal/deps/undici/undici:12345 #52091

yqz945 opened this issue Mar 15, 2024 · 2 comments

Comments

@yqz945
Copy link

yqz945 commented Mar 15, 2024

Version

20.11.1

Platform

Microsoft Windows NT 10.0.22631.0

Subsystem

No response

What steps will reproduce the bug?

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'
  }
}
> await fetch('https://cn.bing.com')
Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: Proxy [
    {
      aborted: false,
      rangeRequested: false,
      timingAllowPassed: true,
      requestIncludesCredentials: true,
      type: 'default',
      status: 200,
      timingInfo: [Object],
      cacheState: '',
      statusText: 'OK',
      headersList: [HeadersList],
      urlList: [Array],
      body: [Object]
    },
    { get: [Function: get], set: [Function: set] }
  ]...

But I can access openai api from browser.
image

I can use openai python sdk to access openai api.
image

And I tried node v18 all of the version have the problem.

How often does it reproduce? Is there a required condition?

100% reproduce.

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

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'
}
}

Additional information

No response

@tannal
Copy link
Contributor

tannal commented Mar 15, 2024

It's a network proxy issue.
see #42814
And it might be an open issue.
see #43187

@RedYetiDev
Copy link
Member

(closing as completed, this seems resolved)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants