opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open ykswang opened this issue 1 week ago • 1 comments

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

ykswang avatar Jan 03 '26 18:01 ykswang