Infinite installation loop of @aws-sdk/credential-providers on startup when AWS_BEARER_TOKEN_BEDROCK is set #4133

Open
opened 2026-02-16 17:42:44 -05:00 by yindo · 2 comments
Owner

Originally created by @ykswang on GitHub (Jan 3, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

OpenCode hangs on startup when the AWS_BEARER_TOKEN_BEDROCK environment variable is set. It triggers a re-installation of @aws-sdk/credential-providers on every single launch, even if the package is already successfully installed.
This becomes a blocking issue if the connection to the npm registry is slow or unstable (e.g., when using a custom registry mirror like npmmirror), causing the CLI to hang indefinitely during the network request.

Verification:
I confirmed that manually modifying ~/.cache/opencode/package.json by changing the version of @aws-sdk/credential-providers from the specific version number (e.g., "3.962.0") to "latest" makes the issue disappear immediately.

Root Cause Analysis:
I investigated the source code and identified the issue in packages/opencode/src/bun/index.ts.

  1. src/provider/provider.ts calls BunProc.install("@aws-sdk/credential-providers") without a version, defaulting to "latest".
  2. BunProc.install compares the installed version in package.json (e.g., "3.962.0") against the requested version ("latest").
  3. Since "3.962.0" !== "latest", it forces a bun add command every time, triggering unnecessary network requests.

Plugins

Default

OpenCode version

1.0.220

Steps to reproduce

  1. Export AWS_BEARER_TOKEN_BEDROCK=test_token in your shell.
  2. Run opencode.
  3. The CLI hangs during initialization.
  4. Running opencode --print-logs shows it is stuck at: INFO service=bun ... installing package using Bun's default registry resolution pkg=@aws-sdk/credential-providers version=latest

Screenshot and/or share link

No response

Operating System

macOS

Terminal

iTerm2

Originally created by @ykswang on GitHub (Jan 3, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description OpenCode hangs on startup when the `AWS_BEARER_TOKEN_BEDROCK` environment variable is set. It triggers a re-installation of `@aws-sdk/credential-providers` on **every single launch**, even if the package is already successfully installed. This becomes a blocking issue if the connection to the npm registry is slow or unstable (e.g., when using a custom registry mirror like npmmirror), causing the CLI to hang indefinitely during the network request. **Verification:** I confirmed that manually modifying `~/.cache/opencode/package.json` by changing the version of `@aws-sdk/credential-providers` from the specific version number (e.g., "3.962.0") to "latest" makes the issue disappear immediately. **Root Cause Analysis:** I investigated the source code and identified the issue in `packages/opencode/src/bun/index.ts`. 1. `src/provider/provider.ts` calls `BunProc.install("@aws-sdk/credential-providers")` without a version, defaulting to "latest". 2. `BunProc.install` compares the installed version in `package.json` (e.g., "3.962.0") against the requested version ("latest"). 3. Since "3.962.0" !== "latest", it forces a `bun add` command every time, triggering unnecessary network requests. ### Plugins Default ### OpenCode version 1.0.220 ### Steps to reproduce 1. Export `AWS_BEARER_TOKEN_BEDROCK=test_token` in your shell. 2. Run `opencode`. 3. The CLI hangs during initialization. 4. Running `opencode --print-logs` shows it is stuck at: `INFO service=bun ... installing package using Bun's default registry resolution pkg=@aws-sdk/credential-providers version=latest` ### Screenshot and/or share link _No response_ ### Operating System macOS ### Terminal iTerm2
yindo added the bugperf labels 2026-02-16 17:42:44 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 3, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4682: opencode get stuck when bun add get stuck - Reports similar hanging issues during package installation, though the root cause may be related to your identified version comparison problem.

Feel free to ignore if your specific case differs from those issues.

@github-actions[bot] commented on GitHub (Jan 3, 2026): This issue might be a duplicate of existing issues. Please check: - #4682: opencode get stuck when `bun add` get stuck - Reports similar hanging issues during package installation, though the root cause may be related to your identified version comparison problem. Feel free to ignore if your specific case differs from those issues.
Author
Owner

@chindris-mihai-alexandru commented on GitHub (Jan 27, 2026):

I experienced the same BunInstallFailedError with @aws-sdk/credential-providers on OpenCode v1.1.36 running on macOS.

Environment: AWS environment variables set (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)

Workaround that worked:

cd ~/.config/opencode
rm bun.lock
npm install @aws-sdk/credential-providers

After this, OpenCode starts normally without the installation loop. Can confirm the npm workaround is effective for this version.

@chindris-mihai-alexandru commented on GitHub (Jan 27, 2026): I experienced the same BunInstallFailedError with @aws-sdk/credential-providers on OpenCode v1.1.36 running on macOS. **Environment:** AWS environment variables set (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION) **Workaround that worked:** ```bash cd ~/.config/opencode rm bun.lock npm install @aws-sdk/credential-providers ``` After this, OpenCode starts normally without the installation loop. Can confirm the npm workaround is effective for this version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4133