Skip to content

fix: prevent Bun from auto-serving the CLI entrypoint - #320

Open
awesamarth wants to merge 1 commit into
stripe:mainfrom
awesamarth:fix/bun-cli-auto-serve
Open

fix: prevent Bun from auto-serving the CLI entrypoint#320
awesamarth wants to merge 1 commit into
stripe:mainfrom
awesamarth:fix/bun-cli-auto-serve

Conversation

@awesamarth

Copy link
Copy Markdown

Summary

Fixes #298.

Bun automatically starts an HTTP server when an entrypoint default-exports an object with a fetch method. The CLI's default export triggers this after ordinary commands print their output, contaminating stdout and keeping the process alive.

Remove that default export while keeping cli.serve() and the explicit serve command unchanged. Include a patch changeset.

Validation

  • Reproduced on Bun 1.3.14: bun packages/cli/dist/cli.js --version printed the version followed by Started development server and did not exit; Node exited normally. The patched build exits cleanly on both runtimes.
  • Packed and installed the patched CLI in an isolated Bun installation. Both bunx and bunx --bun returned parseable auth-status JSON and exited normally (temporary auth storage and a fake environment token; --interval 1 skips the update check).
  • Verified stdio MCP initialization and explicit HTTP serve on Node and Bun. HTTP MCP initialization succeeds; arbitrary command paths remain blocked with 404.
  • Existing CLI suite: 326 tests passed. TypeScript SDK suite: 142 tests passed.
  • Build, typecheck, Biome, and Go SDK formatting, module tidy, vet, and race tests passed.

No command, flag, or schema changes. This is separate from the spinner dependency fix in #312.

@awesamarth
awesamarth requested a review from a team as a code owner September 11, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bunx hangs after link-cli commands by implicitly starting a development server

1 participant