Repository navigation
opencode get stuck when bun add get stuck #4682
Description
Description
What happen:
When I executed opencode, the program froze, akin to a terminal being frozen. I was unable to close it using any method, such as pressing Ctrl+C. When I terminated it from another terminal, I ran it again with the --print-log option and noticed it was stuck at the bun add command. I think we should improve this situation.
I've done some digging and found out why the bun got stuck. It's because my bun encountered a 304 response, and then it just went nowhere. Maybe we should add --no-cache option when run bun.
By the way, I've encountered this error multiple times already; I often have to manually run "bun add."
bun add --cwd /Users/lang/.cache/opencode --force --exact opencode-anthropic-auth@0.0.2 --verbose
bun add v1.3.3 (274e01c7)
- "opencode-anthropic-auth": "0.0.2" - opencode-anthropic-auth@0.0.2
Enqueue package manifest for download: @openauthjs/openauth
🔍 Resolving [1/1] [fetch] > HTTP/1.1 GET https://registry.npmmirror.com/@openauthjs%2fopenauth
[fetch] > If-None-Match: W/"e9e873cea576887a9d66bdd1048dbf983cadbe45"
[fetch] > Accept: application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*
[fetch] > Connection: keep-alive
[fetch] > User-Agent: Bun/1.3.3
[fetch] > Host: registry.npmmirror.com
[fetch] > Accept-Encoding: gzip, deflate, br, zstd
[fetch] < 200 Connection established
[fetch] < 304 Not Modified
[fetch] < Server: Tengine
[fetch] < Connection: keep-alive
[fetch] < Strict-Transport-Security: max-age=5184000
[fetch] < Date: Mon, 24 Nov 2025 08:21:49 GMT
[fetch] < request-id: cb00ed85-d034-4a21-b240-036edd52697a
[fetch] < cache-control: public, max-age=300
[fetch] < x-frame-options: SAMEORIGIN
[fetch] < x-xss-protection: 1; mode=block
[fetch] < x-content-type-options: nosniff
[fetch] < x-download-options: noopen
[fetch] < x-readtime: 1.462
[fetch] < Via: cn8360.l1, kunlun1.cn8360, l2cn8047.l2, cache23.l2cn8047, npmmirror-x86-20220823001, cache23.l2cn8047[0,0,304-0,H], cache34.l2cn8047[1,0], kunlun10.cn7632[32,31,304-0,H], kunlun1.cn7632[34,0]
[fetch] < Vary: Origin, Accept, Accept-Encoding
[fetch] < etag: W/"e9e873cea576887a9d66bdd1048dbf983cadbe45"
[fetch] < Age: 45
[fetch] < Ali-Swift-Global-Savetime: 1763972509
[fetch] < X-Cache: HIT TCP_REFRESH_HIT dirn:-2:-2
[fetch] < X-Swift-SaveTime: Mon, 24 Nov 2025 08:22:34 GMT
[fetch] < X-Swift-CacheTime: 255
[fetch] < Timing-Allow-Origin: *
[fetch] < EagleId: 2493171517639725549608795e
OpenCode version
No response
Steps to reproduce
- run opencode
- get stuck
Screenshot and/or share link
No response
Operating System
macos
Terminal
vscode terminal
Activity
github-actions commentedon Nov 24, 2025
This issue might be a duplicate of existing issues. Please check:
The root cause you've identified (bun hanging on 304 cache responses) appears to be specific to this issue, but the symptom (OpenCode freezing/getting stuck) is also seen in #4672. Feel free to ignore if your specific case differs from those issues.
WAY29 commentedon Nov 24, 2025
Is there a way to prevent opencode from updating bun depends anymore?
rekram1-node commentedon Nov 24, 2025
hmm ill look into it, for this the only work around would be to disable the default plugins that we load (or only work around we currently provide)
jensenojs commentedon Nov 26, 2025
Regarding this issue, I'd like to add another common case: for users in mainland China, updating bun may require configuring a mirror.
https://bun.com/docs/runtime/bunfig
Although I'm not sure whether this information is appropriate, or where it should be mentioned @rekram1-node
WAY29 commentedon Nov 26, 2025
Yes, I am Chinese, I had already add bun mirror, but bun still got stuck when http response 304 status code
rekram1-node commentedon Nov 26, 2025
that's good to know thx
jslorrma commentedon Dec 2, 2025
I'm facing exactly the same issue and therefore cannot use Opencode right now. Is there any temp. workaround to get it working again?
For context, I'm not located in China, but within a corporate network and behind a corporate proxy. I have proxies configured via environment variables (
HTTP_PROXY,HTTPS_PROXY) and by setting them in npm config usingnpm config set proxy ...andnpm config set https-proxy ....driden commentedon Dec 2, 2025
Hey everyone, just wanted to +1 this since I'm having the same issue when opencode goes through the bootstrapping routine.
edit: It seems that after many attempts of launching & having to kill opencode it finally managed to install the dependency and it started working again.
rekram1-node commentedon Dec 2, 2025
There is a known issue w/ proxy stuff Ill get it fixed soon
WAY29 commentedon Dec 4, 2025
Once again, I encountered this problem, and for some reason, the dependencies of opencode I installed disappeared. I then used bun to install opencode again, and I got stuck in bun once more.
WAY29 commentedon Dec 4, 2025
oven-sh/bun#11526
This issue may be somewhat helpful; currently, it seems that the only way to help is for users to disable ipv6 or add —no-cache when adding bun (this appears to be the simplest solution).
jensenojs commentedon Dec 5, 2025
repo because of opencode-dcp
WAY29 commentedon Dec 5, 2025
Once again, I've encountered this issue. It seems that after every auto-update of opencode, the bun dependency gets deleted, leading to this problem cropping up after each auto-update: opencode-anthropic-auth@0.0.4.
WAY29 commentedon Dec 9, 2025
I found a problem, every time I run opencode, bun seems to be trying to install new dependencies, which is too crazy, so I always encounter this issues every time I run opencode.
I also encountered another problem, when I pin a dependency version in the configuration file, the latest version was still downloaded. numman-ali/opencode-openai-codex-auth#60
@rekram1-node can you help me?
klimkin commentedon Dec 15, 2025
Clearing bun cache helped me to unstuck opencode
jensenojs commentedon Dec 18, 2025
once again, but at lease we know why hhh
jensenojs commentedon Dec 18, 2025
@WAY29
driden commentedon Dec 18, 2025
I finally upgraded again today ~ 1hr startup time
jensenojs commentedon Dec 18, 2025
I've tested this on other machines. With the --no-cache option added, it does resolve the issue in scenarios where HTTPS_PROXY would reliably cause hangs. Considering this might be an upstream bug, I'm unsure whether adding the corresponding field is appropriate, but it does affect the experience somewhat. What do you think? @rekram1-node Solving it could probably close around six or seven issues.
ps. When I tried it on that computer, I didn't realize a PR had already been submitted for it by @WAY29
jensenojs commentedon Dec 20, 2025
@rekram1-node
tiann commentedon Dec 23, 2025
There are three ways to bypass:
bun add xxx --nocacheDarkPocket commentedon Jan 12, 2026
but use this registry = "https://registry.npmmirror.com". will have version problems . the newest version still is 1.0.152 .
env :Windows11,power shell。
"""PS D:\Soft> date
2026年1月12日 11:06:16
PS D:\Soft> npm i -g opencode-ai
added 1 package in 825ms
PS D:\Soft> opencode -version
1.0.152
"""
OneOfLzx commentedon Jan 22, 2026
If you’re on a private network, I’d use OpenCode Sentinel — this project includes built-in support for offline dependency configuration, enabling one-click installation of all required dependencies without any network access 👍👍.
Also, it cuts all network access except to your LLM, so it works flawlessly in network-restricted environments.
Repo: https://github.com/oneoflzx/opencode-sentinel
github-actions commentedon Mar 28, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.