[GH-ISSUE #366] fetch failed #72

Closed
opened 2026-03-03 13:52:45 +03:00 by kerem · 4 comments
Owner

Originally created by @luyangsuper on GitHub (Mar 11, 2025).
Original GitHub issue: https://github.com/jehna/humanify/issues/366

I can't connect using my OpenAI key or Gemini key. I'm sure there's no problem with my network and it can be accessed normally. Why is this happening?

Image

Originally created by @luyangsuper on GitHub (Mar 11, 2025). Original GitHub issue: https://github.com/jehna/humanify/issues/366 I can't connect using my OpenAI key or Gemini key. I'm sure there's no problem with my network and it can be accessed normally. Why is this happening? ![Image](https://github.com/user-attachments/assets/6f0bc6cf-204d-4626-be4f-ca81ebcc8842)
kerem closed this issue 2026-03-03 13:52:45 +03:00
Author
Owner

@0xdevalias commented on GitHub (Mar 11, 2025):

I haven't looked deeply into this, but based on the error log you provided there, it seems to be happening within the @google/generative-ai package. Some potentially related issues from that upstream package:

From a google of "node internal deps undici", a few more potentially related issues popped up"

There are also the following issues in this repo that sound like they might be tangentially related, but are probably unlikely to be the same root cause:

You said this is also happening with OpenAI? If so, are you able to provide some error logs when that occurs? (ideally as text within triple backtick code blocks rather than a screenshot)

It might also help to get more information if you pass --verbose:

github.com/jehna/humanify@8a054d7e8f/src/commands/gemini.ts (L25)

Can you also confirm some basic details like what version of Node you are using, what platform you are using (seemingly windows?), whether you are running this in WSL, at what point of the program execution this occurs (I see "Processing file 1/1" in the error logs above), etc.

Based on your initial report, there isn't a lot of details to work with to understand/debug why this might be occurring.

<!-- gh-comment-id:2712668497 --> @0xdevalias commented on GitHub (Mar 11, 2025): I haven't looked deeply into this, but based on the error log you provided there, it seems to be happening within the `@google/generative-ai` package. Some potentially related issues from that upstream package: - https://github.com/google-gemini/generative-ai-js/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20%22fetch%20failed%22 - https://github.com/google-gemini/generative-ai-js/issues/29 - > I was facing the same issue. > > I switched to node version `20` from `18`, it started to work. > > _Originally posted by @duke79 in https://github.com/google-gemini/generative-ai-js/issues/29#issuecomment-2160992763_ - There are also a lot of posts in this issue that seem to talk about this potentially being related to Chinese internet connections being unable to talk to Google; unsure if that is relevant here, but if so, then these issues may also be relevant: - https://github.com/jehna/humanify/issues/68 - https://github.com/jehna/humanify/issues/265 - https://github.com/jehna/humanify/issues/212 - https://github.com/google-gemini/generative-ai-js/issues/360 From a google of "node internal deps undici", a few more potentially related issues popped up" - https://github.com/nodejs/undici/issues/3492 - https://github.com/nodejs/node/issues/45497 There are also the following issues in this repo that sound like they might be tangentially related, but are probably unlikely to be the same root cause: - https://github.com/jehna/humanify/issues/2 - https://github.com/jehna/humanify/issues/139 You said this is also happening with OpenAI? If so, are you able to provide some error logs when that occurs? (ideally [as text within triple backtick code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks) rather than a screenshot) It might also help to get more information if you pass `--verbose`: https://github.com/jehna/humanify/blob/8a054d7e8ff5e68eb0377f7252117093bae36f93/src/commands/gemini.ts#L25 Can you also confirm some basic details like what version of Node you are using, what platform you are using (seemingly windows?), whether you are running this in WSL, at what point of the program execution this occurs (I see "Processing file 1/1" in the error logs above), etc. Based on your initial report, there isn't a lot of details to work with to understand/debug why this might be occurring.
Author
Owner

@luyangsuper commented on GitHub (Mar 11, 2025):

Indeed, I ran this command in Windows.

1. gemini

Processing file 1/1
[2025-03-11 06:01:08]  Renaming a
[2025-03-11 06:01:08]  Context:  function a(e, t) {
  var n = [];
  var r = e.length;
  var i = 0;
  for (; i < r; i += t) {
    if (i + t < r) {
      n.push(e.substring(i, i + t));
    } else {
      n.push(e.substring(i, r));
    }
  }
  return n;
}
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

TypeError: fetch failed
    at node:internal/deps/undici/undici:13502:13
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)   
    at async makeRequest (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/@google/generative-ai/dist/index.mjs:368:20)
    at async generateContent (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/@google/generative-ai/dist/index.mjs:817:22)
    at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55319:24
    at async visitAllIdentifiers (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55082:21)
    at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55311:12
    at async unminify (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:172:27)
    at async Command.<anonymous> (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55366:3)

Node.js v22.14.0

2. openai

Processing file 1/1
[2025-03-11 06:04:58]  Renaming a
[2025-03-11 06:04:58]  Context:  function a(e, t) {
  var n = [];
  var r = e.length;
  var i = 0;
  for (; i < r; i += t) {
    if (i + t < r) {
      n.push(e.substring(i, i + t));
    } else {
      n.push(e.substring(i, r));
    }
  }
  return n;
}
file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/openai/core.mjs:322
            throw new APIConnectionError({ cause: response });
                  ^

APIConnectionError: Connection error.
    at OpenAI.makeRequest (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/openai/core.mjs:322:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55216:26
    at async visitAllIdentifiers (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55082:21)
    at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55210:12
    at async unminify (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:172:27)
    at async Command.<anonymous> (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55292:3) {
  status: undefined,
  headers: undefined,
  request_id: undefined,
  error: undefined,
  code: undefined,
  param: undefined,
  type: undefined,
  cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason: connect ETIMEDOUT 128.242.250.155:443
      at ClientRequest.<anonymous> (C:\Users\subar\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\node-fetch\lib\index.js:1501:11)
      at ClientRequest.emit (node:events:518:28)
      at emitErrorEvent (node:_http_client:104:11)
      at TLSSocket.socketErrorListener (node:_http_client:518:5)
      at TLSSocket.emit (node:events:530:35)
      at emitErrorNT (node:internal/streams/destroy:170:8)
      at emitErrorCloseNT (node:internal/streams/destroy:129:3)
      at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
    type: 'system',
    errno: 'ETIMEDOUT',
    code: 'ETIMEDOUT'
  }
}

Node.js v22.14.0
<!-- gh-comment-id:2712784049 --> @luyangsuper commented on GitHub (Mar 11, 2025): Indeed, I ran this command in Windows. **1. gemini** ``` Processing file 1/1 [2025-03-11 06:01:08] Renaming a [2025-03-11 06:01:08] Context: function a(e, t) { var n = []; var r = e.length; var i = 0; for (; i < r; i += t) { if (i + t < r) { n.push(e.substring(i, i + t)); } else { n.push(e.substring(i, r)); } } return n; } node:internal/process/promises:394 triggerUncaughtException(err, true /* fromPromise */); ^ TypeError: fetch failed at node:internal/deps/undici/undici:13502:13 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async makeRequest (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/@google/generative-ai/dist/index.mjs:368:20) at async generateContent (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/@google/generative-ai/dist/index.mjs:817:22) at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55319:24 at async visitAllIdentifiers (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55082:21) at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55311:12 at async unminify (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:172:27) at async Command.<anonymous> (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55366:3) Node.js v22.14.0 ``` **2. openai** ``` Processing file 1/1 [2025-03-11 06:04:58] Renaming a [2025-03-11 06:04:58] Context: function a(e, t) { var n = []; var r = e.length; var i = 0; for (; i < r; i += t) { if (i + t < r) { n.push(e.substring(i, i + t)); } else { n.push(e.substring(i, r)); } } return n; } file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/openai/core.mjs:322 throw new APIConnectionError({ cause: response }); ^ APIConnectionError: Connection error. at OpenAI.makeRequest (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/node_modules/openai/core.mjs:322:19) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55216:26 at async visitAllIdentifiers (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55082:21) at async file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55210:12 at async unminify (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:172:27) at async Command.<anonymous> (file:///C:/Users/subar/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:55292:3) { status: undefined, headers: undefined, request_id: undefined, error: undefined, code: undefined, param: undefined, type: undefined, cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason: connect ETIMEDOUT 128.242.250.155:443 at ClientRequest.<anonymous> (C:\Users\subar\AppData\Roaming\npm\node_modules\humanifyjs\node_modules\node-fetch\lib\index.js:1501:11) at ClientRequest.emit (node:events:518:28) at emitErrorEvent (node:_http_client:104:11) at TLSSocket.socketErrorListener (node:_http_client:518:5) at TLSSocket.emit (node:events:530:35) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT' } } Node.js v22.14.0 ```
Author
Owner

@0xdevalias commented on GitHub (Mar 11, 2025):

I ran this command in Windows

I'm not deeply familiar with windows, so unfortunately my help may not be as useful as it could be on another platform.

And looks like you were running in cmd.exe or powershell.exe rather than WSL? (not sure if that is relevant, but just to narrow down potential issues)

In the openai error I see:

cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason: connect ETIMEDOUT 128.242.250.155:443

Which suggests that api.openai.com resolved to 128.242.250.155, yet when I look up the IP address associate with their API, I get:

⇒ dig A api.openai.com

; <<>> DiG 9.10.6 <<>> A api.openai.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31195
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;api.openai.com.			IN	A

;; ANSWER SECTION:
api.openai.com.		7	IN	A	162.159.140.245
api.openai.com.		7	IN	A	172.66.0.243

;; Query time: 9 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Tue Mar 11 17:23:22 AEDT 2025
;; MSG SIZE  rcvd: 75

And the IP address you're getting seems to be assigned to NTT:

Do you have any network based restrictions, VPNs, proxies, firewalls, etc that might be interfering? Or possibly on something like a public wifi network that might have 'captive portal' or similar sort of things setup?

I'm sure there's no problem with my network and it can be accessed normally.

When you say "can be accessed normally", how are you accessing it 'normally' that works? Just through a web browser? Or are you able to get a basic example PoC request running node and using the OpenAI and/or Gemini libraries to work from that same terminal? (Or maybe even a manual request using some windows equivalent to curl/etc)

<!-- gh-comment-id:2712817453 --> @0xdevalias commented on GitHub (Mar 11, 2025): > I ran this command in Windows I'm not deeply familiar with windows, so unfortunately my help may not be as useful as it could be on another platform. And looks like you were running in `cmd.exe` or `powershell.exe` rather than WSL? (not sure if that is relevant, but just to narrow down potential issues) In the `openai` error I see: ``` cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason: connect ETIMEDOUT 128.242.250.155:443 ``` Which suggests that `api.openai.com` resolved to `128.242.250.155`, yet when I look up the IP address associate with their API, I get: ```shell ⇒ dig A api.openai.com ; <<>> DiG 9.10.6 <<>> A api.openai.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31195 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; QUESTION SECTION: ;api.openai.com. IN A ;; ANSWER SECTION: api.openai.com. 7 IN A 162.159.140.245 api.openai.com. 7 IN A 172.66.0.243 ;; Query time: 9 msec ;; SERVER: 1.1.1.1#53(1.1.1.1) ;; WHEN: Tue Mar 11 17:23:22 AEDT 2025 ;; MSG SIZE rcvd: 75 ``` And the IP address you're getting seems to be assigned to NTT: - https://whoismind.com/ips/128.242.250.0/24 Do you have any network based restrictions, VPNs, proxies, firewalls, etc that might be interfering? Or possibly on something like a public wifi network that might have 'captive portal' or similar sort of things setup? > I'm sure there's no problem with my network and it can be accessed normally. When you say "can be accessed normally", how are you accessing it 'normally' that works? Just through a web browser? Or are you able to get a basic example PoC request running `node` and using the OpenAI and/or Gemini libraries to work from that same terminal? (Or maybe even a manual request using some windows equivalent to `curl`/etc)
Author
Owner

@0xdevalias commented on GitHub (Mar 11, 2025):

@luyangsuper I see you closed this as completed.. was that by mistake, or did you resolve the issue? And if the latter, are you able to share what the solution was?

<!-- gh-comment-id:2712822824 --> @0xdevalias commented on GitHub (Mar 11, 2025): @luyangsuper I see you closed this as completed.. was that by mistake, or did you resolve the issue? And if the latter, are you able to share what the solution was?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/humanify#72
No description provided.