gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

[API Error: Premature close]

Open jmluang opened this issue 1 year ago • 18 comments

What happened?

When I asked the gemini to do something, gemini give me the plan ,but failed to apply the code to the file

Image

error in log file

"error": {
    "message": "Premature close",
    "stack": "Error: Premature close\n    at IncomingMessage.<anonymous> (file:///Users/luang/.npm/_npx/38c708f8d73fe4c9/node_modules/@google/gemini-cli/bundle/gemini.js:50463:27)\n    at Object.onceWrapper (node:events:632:28)\n    at IncomingMessage.emit (node:events:518:28)\n    at emitCloseNT (node:internal/streams/destroy:147:10)\n    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)"
}
│                                                                                                                      │
│  Agent powering down. Goodbye!                                                                                       │
│                                                                                                                      │
│  Performance                                                                                                         │
│  Wall Time:                  11m 54s                                                                                 │
│  Agent Active:               4m 9s                                                                                   │
│    » API Time:               4m 9s (100.0%)                                                                          │
│    » Tool Time:              0s (0.0%)                                                                               │
│                                                                                                                      │
│                                                                                                                      │
│  Model Usage                  Reqs   Input Tokens  Output Tokens                                                     │
│  ───────────────────────────────────────────────────────────────                                                     │
│  gemini-2.5-pro                  2              0              0                                                     │

My operating system is: darwin

What did you expect to happen?

code should apply to file

Client information

╭──────────────────────────────────────────────────────────╮
│                                                          │
│ About Gemini CLI                                         │
│                                                          │
│ CLI Version         0.1.12                               │
│ Model               gemini-2.5-pro                       │
│ Sandbox             no sandbox                           │
│ OS                  darwin                               │
│ Auth Method         OAuth                                │
│ GCP Project         linen-flux-465807-j8                 │
│                                                          │
╰──────────────────────────────────────────────────────────╯

Login information

Google Account with cloud project id

Anything else we need to know?

No response

jmluang avatar Jul 15 '25 15:07 jmluang

https://github.com/google-gemini/gemini-cli/blob/7c3a84075d03c84687339904c6421728fe520a6c/packages/core/src/tools/shell.ts#L418

Why write this here? ~~It will trigger this question.~~

warmhug avatar Jul 23 '25 07:07 warmhug

Same problem, CLI wireless loop is calling, but it all says "[API Error: Premature close]", after waiting for more than 20 minutes, I press ESC, and then it crashes and exits.

Image

aiqinxuancai avatar Aug 18 '25 10:08 aiqinxuancai

Same issue,.Is it a bug? Or caused by chinese firewall?

qzqsmile avatar Aug 19 '25 12:08 qzqsmile

china gcd 特色

mrjlovetian avatar Aug 20 '25 06:08 mrjlovetian

fuck GFW

myplxdm avatar Aug 26 '25 02:08 myplxdm

Try to update Gemini CLI?

npm install -g @google/gemini-cli@latest

My Gemini was back online after updating

EvanHong99 avatar Sep 08 '25 13:09 EvanHong99

Oh boy, this pesky error just can't resist making a comeback the second you let the version sit idle for a month or two.

Naturally, the tried-and-true path to salvation appears to be none other than npm install -g @google/gemini-cli@latest.

qlagrangian avatar Nov 03 '25 10:11 qlagrangian

2025-11-11, infinitely repeating [API Error: Premature close], is Gemini still usable? The user experience is getting worse and worse.

heathzhang35 avatar Nov 11 '25 13:11 heathzhang35

Same issue

Evopower avatar Nov 28 '25 13:11 Evopower

Since getting access to 3.0 in the CLI, every single request is getting the same issue identified here. I also seems to keep being told i'm on older versions even though I am now and I have removed gemini-cli from my system and re-added it.

Node 24.12.0 Windows 11 Pro Version: 25H2

│ About Gemini CLI
│
│ CLI Version 0.22.0 │ Git Commit f9331b160 │ Model auto-gemini-3 │ Sandbox no sandbox │ OS win32 │ Auth Method OAuth

gemini --yolo is the command used to invoke Gemini. I have not been able to get a siccesfull response after 7 tries. Giving up.

Image

DEMORALIZ3D avatar Dec 22 '25 18:12 DEMORALIZ3D

您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you

Evopower avatar Dec 22 '25 18:12 Evopower

Same issue, still going on.

Savic avatar Jan 06 '26 20:01 Savic

您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you

Evopower avatar Jan 06 '26 20:01 Evopower

same here.

I experienced a "Premature close" error when attempting to write multiple files consecutively using the write_file tool. Specifically, after successfully writing an initial file (index.html), subsequent calls to write_file (for style.css, script.js) consistently failed with this error.

InfantLab avatar Jan 07 '26 12:01 InfantLab

It's been months and I am still getting this. Google blames this in client side connection which is complete BS. This has got to be fixed. I can't believe I am paying for this!

shcheah avatar Jan 28 '26 00:01 shcheah

您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you

Evopower avatar Jan 28 '26 00:01 Evopower

换个节点试试?

EvanHong99 avatar Mar 05 '26 14:03 EvanHong99

@jmluang, this issue has been inactive for over a month. Could you please try reproducing it with the latest nightly build and let us know if it still occurs? If we don't hear back, we will close this issue on 2026-04-23.

cocosheng-g avatar Apr 09 '26 16:04 cocosheng-g