Skip to content

Commit c3a73ec

Browse files
fix(cli): don't crash auth login when no browser opener is available (#56082)
Co-authored-by: thdxr <thdxr@users.noreply.github.com>
1 parent e1bba47 commit c3a73ec

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/cli/src/ui/prompt.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export function requireInteractive(message: string) {
1717

1818
export const openUrl = Effect.fn("cli.prompt.open-url")(function* (url: string) {
1919
const browser = yield* Effect.promise(() => import("@opencode/util/open"))
20-
yield* Effect.promise(() => browser.openUrl(url)).pipe(Effect.ignore)
20+
// Best effort: headless environments may lack a browser opener, and the caller already printed the URL.
21+
yield* Effect.tryPromise(() => browser.openUrl(url)).pipe(Effect.ignore)
2122
})
2223

2324
export function handlePromptErrors<A, E, R>(effect: Effect.Effect<A, E, R>) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from "bun:test"
2+
import { Effect, Exit } from "effect"
3+
import { openUrl } from "../src/ui/prompt"
4+
5+
test("suppresses browser open failures so the printed URL stays usable", async () => {
6+
const exit = await Effect.runPromiseExit(openUrl("not-a-browser-url"))
7+
expect(Exit.isSuccess(exit)).toBe(true)
8+
})

0 commit comments

Comments
 (0)