Skip to content

opencode get stuck when bun add get stuck #4682

Closed

Description

@WAY29

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

  1. run opencode
  2. get stuck

Screenshot and/or share link

No response

Operating System

macos

Terminal

vscode terminal

Activity

  1. github-actions commented on Nov 24, 2025

    @github-actions
    Contributor

    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.

  2. WAY29 commented on Nov 24, 2025

    @WAY29
    ContributorAuthor

    Is there a way to prevent opencode from updating bun depends anymore?

  3. self-assigned this
    on Nov 24, 2025
  4. rekram1-node commented on Nov 24, 2025

    @rekram1-node
    Collaborator

    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)

  5. jensenojs commented on Nov 26, 2025

    @jensenojs
    Contributor

    Regarding this issue, I'd like to add another common case: for users in mainland China, updating bun may require configuring a mirror.

    Image

    https://bun.com/docs/runtime/bunfig

    [install]
    registry = "https://registry.npmmirror.com"
    

    Although I'm not sure whether this information is appropriate, or where it should be mentioned @rekram1-node

  6. WAY29 commented on Nov 26, 2025

    @WAY29
    ContributorAuthor

    Regarding this issue, I'd like to add another common case: for users in mainland China, updating bun may require configuring a mirror.

    Image https://bun.com/docs/runtime/bunfig

    [install]
    registry = "https://registry.npmmirror.com"
    Although I'm not sure whether this information is appropriate, or where it should be mentioned @rekram1-node

    Yes, I am Chinese, I had already add bun mirror, but bun still got stuck when http response 304 status code

  7. rekram1-node commented on Nov 26, 2025

    @rekram1-node
    Collaborator

    that's good to know thx

  8. jslorrma commented on Dec 2, 2025

    @jslorrma

    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 using npm config set proxy ... and npm config set https-proxy ....

  9. driden commented on Dec 2, 2025

    @driden

    Hey everyone, just wanted to +1 this since I'm having the same issue when opencode goes through the bootstrapping routine.

    INFO  2025-12-02T14:47:40 +166ms service=server method=GET path=/ request
    INFO  2025-12-02T14:47:40 +0ms service=server status=started method=GET path=/ request
    INFO  2025-12-02T14:47:40 +1ms service=default directory=/Users/user/.config/opencode creating instance
    INFO  2025-12-02T14:47:40 +0ms service=project directory=/Users/user/.config/opencode fromDirectory
    INFO  2025-12-02T14:47:40 +2ms service=default directory=/Users/user/.config/opencode bootstrapping
    INFO  2025-12-02T14:47:40 +2ms service=config path=/Users/user/.config/opencode/config.json loading
    INFO  2025-12-02T14:47:40 +0ms service=config path=/Users/user/.config/opencode/opencode.json loading
    INFO  2025-12-02T14:47:40 +2ms service=config path=/Users/user/.config/opencode/opencode.jsonc loading
    INFO  2025-12-02T14:47:40 +1ms service=config path=/Users/user/.config/opencode/opencode.json loading
    INFO  2025-12-02T14:47:40 +2ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.126/libexec/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@1.0.126","--exact"] cwd=/Users/user/.config/opencode running
    

    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.

  10. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Collaborator

    There is a known issue w/ proxy stuff Ill get it fixed soon

  11. WAY29 commented on Dec 4, 2025

    @WAY29
    ContributorAuthor

    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.

  12. WAY29 commented on Dec 4, 2025

    @WAY29
    ContributorAuthor

    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.

    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).

  13. jensenojs commented on Dec 5, 2025

    @jensenojs
    Contributor

    repo because of opencode-dcp

    Image
    INFO  2025-12-05T09:06:31 +2ms service=server status=started method=GET path=/event request
    INFO  2025-12-05T09:08:27 +115632ms service=bun code=0 stdout=bun add v1.3.3 (274e01c7)
    
    installed @tarquinen/opencode-dcp@0.4.2
    
    115 packages installed [721.63s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [71]
    Saved lockfile
     done
    INFO  2025-12-05T09:08:27 +96ms service=plugin path=file:///Users/oujinsai/.config/opencode/plugin/notification.js loading plugin
    INFO  2025-12-05T09:08:27 +1ms service=plugin path=file:///Users/oujinsai/.config/opencode/plugin/env-protection.js loading plugin
    INFO  2025-12-05T09:08:27 +0ms service=plugin path=opencode-copilot-auth@0.0.8 loading plugin
    INFO  2025-12-05T09:08:27 +2ms service=bun pkg=opencode-copilot-auth version=0.0.8 installing package using Bun's default registry resolution
    INFO  2025-12-05T09:08:27 +0ms service=bun pkg=opencode-copilot-auth version=0.0.8 attempt=1 total=3 bun install attempt
    INFO  2025-12-05T09:08:27 +0ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.133/bin/opencode","add","--force","--exact","--cwd","/Users/oujinsai/.cache/opencode","opencode-copilot-auth@0.0.8"] cwd=/Users/oujinsai/.cache/opencode running
    INFO  2025-12-05T09:10:28 +120663ms service=bun code=0 stdout=bun add v1.3.3 (274e01c7)
    
    + @tarquinen/opencode-dcp@0.4.2
    
    installed opencode-copilot-auth@0.0.8
    
    116 packages installed [120.65s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [5]
    Saved lockfile
     done
    INFO  2025-12-05T09:10:28 +38ms service=plugin path=opencode-anthropic-auth@0.0.4 loading plugin
    INFO  2025-12-05T09:10:28 +5ms service=bun pkg=opencode-anthropic-auth version=0.0.4 installing package using Bun's default registry resolution
    INFO  2025-12-05T09:10:28 +0ms service=bun pkg=opencode-anthropic-auth version=0.0.4 attempt=1 total=3 bun install attempt
    INFO  2025-12-05T09:10:28 +0ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.133/bin/opencode","add","--force","--exact","--cwd","/Users/oujinsai/.cache/opencode","opencode-anthropic-auth@0.0.4"] cwd=/Users/oujinsai/.cache/opencode running
    ...
    
  14. WAY29 commented on Dec 5, 2025

    @WAY29
    ContributorAuthor

    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.

  15. WAY29 commented on Dec 9, 2025

    @WAY29
    ContributorAuthor

    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?

  16. klimkin commented on Dec 15, 2025

    @klimkin

    Clearing bun cache helped me to unstuck opencode

    bun pm cache rm
    
  17. jensenojs commented on Dec 18, 2025

    @jensenojs
    Contributor

    once again, but at lease we know why hhh

    Image
  18. jensenojs commented on Dec 18, 2025

    @jensenojs
    Contributor

    @WAY29

    Image
    rm -rf ~/.cache/opencode && /usr/bin/time -lp opencode --print-logs
  19. driden commented on Dec 18, 2025

    @driden

    I finally upgraded again today ~ 1hr startup time

    INFO  2025-12-18T13:59:17 +0ms service=server method=GET path=/event request
    INFO  2025-12-18T13:59:17 +0ms service=server status=started method=GET path=/event request
    INFO  2025-12-18T13:59:17 +12ms service=default directory=/Users/ilou/code/Atlas_Acceptance_Tests bootstrapping
    INFO  2025-12-18T13:59:17 +1ms service=config path=/Users/ilou/.config/opencode/config.json loading
    INFO  2025-12-18T13:59:17 +1ms service=config path=/Users/ilou/.config/opencode/opencode.json loading
    INFO  2025-12-18T13:59:17 +1ms service=config path=/Users/ilou/.config/opencode/opencode.jsonc loading
    INFO  2025-12-18T13:59:17 +2ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.167/libexec/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@1.0.167","--exact"] cwd=/Users/ilou/.config/opencode running
    INFO  2025-12-18T13:59:17 +1ms service=config path=/Users/ilou/code/Atlas_Acceptance_Tests/.opencode/opencode.jsonc loading
    INFO  2025-12-18T13:59:17 +0ms service=config path=/Users/ilou/code/Atlas_Acceptance_Tests/.opencode/opencode.json loading
    INFO  2025-12-18T13:59:17 +2ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.167/libexec/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode","add","@opencode-ai/plugin@1.0.167","--exact"] cwd=/Users/ilou/code/Atlas_Acceptance_Tests/.opencode running
    INFO  2025-12-18T14:05:32 +375338ms service=bun code=0 stdout=bun add v1.3.4 (5eb2145b)
    
    installed @opencode-ai/plugin@1.0.167
    
    2 packages installed [375.33s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [2]
    Saved lockfile
     done
    INFO  2025-12-18T14:05:32 +323ms service=bun code=0 stdout=bun add v1.3.4 (5eb2145b)
    
    installed @opencode-ai/plugin@1.0.167
    
    2 packages installed [375.65s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [2]
    Saved lockfile
     done
    INFO  2025-12-18T14:05:32 +8ms service=plugin path=opencode-copilot-auth@0.0.9 loading plugin
    INFO  2025-12-18T14:05:32 +2ms service=bun pkg=opencode-copilot-auth version=0.0.9 installing package using Bun's default registry resolution
    INFO  2025-12-18T14:05:32 +0ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.167/libexec/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode","add","--force","--exact","--cwd","/Users/ilou/.cache/opencode","opencode-copilot-auth@0.0.9"] cwd=/Users/ilou/.cache/opencode running
    INFO  2025-12-18T14:11:48 +375307ms service=bun code=0 stdout=bun add v1.3.4 (5eb2145b)
    
    installed opencode-copilot-auth@0.0.9
    
    1 package installed [375.28s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [4]
    Saved lockfile
     done
    INFO  2025-12-18T14:11:48 +26ms service=plugin path=opencode-anthropic-auth@0.0.5 loading plugin
    INFO  2025-12-18T14:11:48 +0ms service=bun pkg=opencode-anthropic-auth version=0.0.5 installing package using Bun's default registry resolution
    INFO  2025-12-18T14:11:48 +0ms service=bun cmd=["/opt/homebrew/Cellar/opencode/1.0.167/libexec/lib/node_modules/opencode-ai/node_modules/opencode-darwin-arm64/bin/opencode","add","--force","--exact","--cwd","/Users/ilou/.cache/opencode","opencode-anthropic-auth@0.0.5"] cwd=/Users/ilou/.cache/opencode running                                                                                                                                                                                                       INFO  2025-12-18T14:50:32 +2324281ms service=bun code=0 stdout=bun add v1.3.4 (5eb2145b)
    
    + opencode-copilot-auth@0.0.9
    
    installed opencode-anthropic-auth@0.0.5
    
    14 packages installed [2324.25s]
     stderr=Resolving dependencies
    Resolved, downloaded and extracted [10]
    Saved lockfile
     done
    INFO  2025-12-18T14:50:32 +23ms service=bus type=* subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=session.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=message.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=message.part.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=session.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=message.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=message.part.updated subscribing
    INFO  2025-12-18T14:50:32 +0ms service=bus type=session.diff subscribing
    INFO  2025-12-18T14:50:32 +0ms service=format init
    INFO  2025-12-18T14:50:32 +0ms service=bus type=file.edited subscribing
    INFO  2025-12-18T14:50:32 +0ms service=lsp serverIds=deno, typescript, vue, eslint, biome, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, fsharp, sourcekit-lsp, rust, clangd, svelte, astro, jdtls, yaml-ls, lua-ls, php intelephense, dart, ocaml-lsp, bash, terraform, texlab, dockerfile, gleam enabled LSP servers
    INFO  2025-12-18T14:50:32 +0ms service=file.watcher init
    INFO  2025-12-18T14:50:32 +2ms service=bus type=command.executed subscribing
    INFO  2025-12-18T14:50:32 +1ms service=file.watcher platform=darwin backend=fs-events watcher backend
    INFO  2025-12-18T14:50:32 +2ms service=server status=started providers
    INFO  2025-12-18T14:50:32 +1ms service=provider status=started state
    INFO  2025-12-18T14:50:32 +1ms service=server event connected
    INFO  2025-12-18T14:50:32 +1ms service=bus type=* subscribing
    INFO  2025-12-18T14:50:32 +3ms service=models.dev file={} refreshing
    INFO  2025-12-18T14:50:32 +0ms service=models.dev file={} refreshing
    INFO  2025-12-18T14:50:32 +1ms service=server status=completed duration=3075340 method=GET path=/event request
    INFO  2025-12-18T14:50:32 +0ms service=server status=completed duration=3075340 method=GET path=/config request
    INFO  2025-12-18T14:50:32 +1ms service=server status=completed duration=3075341 method=GET path=/agent request
    INFO  2025-12-18T14:50:32 +8ms service=provider init
    INFO  2025-12-18T14:50:33 +464ms service=vcs branch=no_jira_disable_account_statements_tests initialized
    INFO  2025-12-18T14:50:33 +0ms service=bus type=file.watcher.updated subscribing
    INFO  2025-12-18T14:50:33 +15ms service=provider providerID=github-copilot found
    INFO  2025-12-18T14:50:33 +0ms service=provider providerID=opencode found
    INFO  2025-12-18T14:50:33 +0ms service=provider status=completed duration=494 state
    INFO  2025-12-18T14:50:33 +8ms service=server status=completed duration=503 providers
    INFO  2025-12-18T14:50:33 +1ms service=server status=completed duration=3075837 method=GET path=/provider request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=3075838 method=GET path=/config/providers request
    INFO  2025-12-18T14:50:33 +23ms service=server method=GET path=/session request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/session request
    INFO  2025-12-18T14:50:33 +0ms service=server method=GET path=/command request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/command request
    INFO  2025-12-18T14:50:33 +1ms service=server status=completed duration=1 method=GET path=/command request
    INFO  2025-12-18T14:50:33 +0ms service=server method=GET path=/lsp request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/lsp request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=0 method=GET path=/lsp request
    INFO  2025-12-18T14:50:33 +1ms service=server method=GET path=/mcp request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/mcp request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=0 method=GET path=/mcp request
    INFO  2025-12-18T14:50:33 +1ms service=server method=GET path=/formatter request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/formatter request
    INFO  2025-12-18T14:50:33 +5ms service=server method=GET path=/session/status request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/session/status request
    INFO  2025-12-18T14:50:33 +1ms service=server status=completed duration=1 method=GET path=/session/status request
    INFO  2025-12-18T14:50:33 +2ms service=server method=GET path=/provider/auth request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/provider/auth request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=0 method=GET path=/provider/auth request
    INFO  2025-12-18T14:50:33 +1ms service=server method=GET path=/vcs request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/vcs request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=0 method=GET path=/vcs request
    INFO  2025-12-18T14:50:33 +1ms service=server method=GET path=/path request
    INFO  2025-12-18T14:50:33 +0ms service=server status=started method=GET path=/path request
    INFO  2025-12-18T14:50:33 +0ms service=server status=completed duration=0 method=GET path=/path request
    INFO  2025-12-18T14:50:33 +28ms service=server status=completed duration=38 method=GET path=/formatter request
    INFO  2025-12-18T14:50:33 +73ms service=server status=completed duration=114 method=GET path=/session request
    
  20. jensenojs commented on Dec 18, 2025

    @jensenojs
    Contributor

    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

  21. jensenojs commented on Dec 20, 2025

    @jensenojs
    Contributor
  22. tiann commented on Dec 23, 2025

    @tiann

    There are three ways to bypass:

    1. bun add xxx --nocache
    2. export all_proxy=xxxx
    3. export NO_PROXY=nmpjs.com
  23. DarkPocket commented on Jan 12, 2026

    @DarkPocket

    Regarding this issue, I'd like to add another common case: for users in mainland China, updating bun may require configuring a mirror.

    Image https://bun.com/docs/runtime/bunfig

    [install]
    registry = "https://registry.npmmirror.com"
    Although I'm not sure whether this information is appropriate, or where it should be mentioned @rekram1-node

    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
    """

  24. OneOfLzx commented on Jan 22, 2026

    @OneOfLzx

    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

  25. github-actions commented on Mar 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions