From c677042f05e78b71cb9df4696c3cd1dc902aa675 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 11 Feb 2026 00:43:23 +0900 Subject: [PATCH] fix(cli-run): set default timeout to 10 minutes and attach immediate .catch() on event processor DEFAULT_TIMEOUT_MS was 0 (no timeout), causing opencode run to hang forever if the session never completed. Also attached .catch() to processEvents() immediately to prevent unhandled promise rejections before Promise.race. --- src/cli/run/runner.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cli/run/runner.ts b/src/cli/run/runner.ts index 762fa487b..e913389b5 100644 --- a/src/cli/run/runner.ts +++ b/src/cli/run/runner.ts @@ -11,7 +11,7 @@ import { pollForCompletion } from "./poll-for-completion" export { resolveRunAgent } -const DEFAULT_TIMEOUT_MS = 0 +const DEFAULT_TIMEOUT_MS = 600_000 export async function run(options: RunOptions): Promise { process.env.OPENCODE_CLI_RUN_MODE = "true" @@ -67,7 +67,9 @@ export async function run(options: RunOptions): Promise { const ctx: RunContext = { client, sessionID, directory, abortController } const events = await client.event.subscribe() const eventState = createEventState() - const eventProcessor = processEvents(ctx, events.stream, eventState) + const eventProcessor = processEvents(ctx, events.stream, eventState).catch( + () => {}, + ) console.log(pc.dim("\nSending prompt...")) await client.session.promptAsync({ @@ -85,7 +87,7 @@ export async function run(options: RunOptions): Promise { // Abort the event stream to stop the processor abortController.abort() - await eventProcessor.catch(() => {}) + await eventProcessor cleanup() const durationMs = Date.now() - startTime @@ -126,4 +128,3 @@ export async function run(options: RunOptions): Promise { } } -