From dd12928390ed838f5d219652019ed707e967f89b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 27 Dec 2025 23:06:44 +0900 Subject: [PATCH] fix: resolve GitHub Actions workflow hang after task completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add process.exit(0) in runner.ts for immediate termination - Fix Timer type to ReturnType in manager.ts - Add .unref() to BackgroundManager polling interval - Add cleanup() method to BackgroundManager 🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/cli/run/runner.ts | 8 ++------ src/features/background-agent/manager.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cli/run/runner.ts b/src/cli/run/runner.ts index f245fd2..1013d9f 100644 --- a/src/cli/run/runner.ts +++ b/src/cli/run/runner.ts @@ -91,19 +91,15 @@ export async function run(options: RunOptions): Promise { if (eventState.mainSessionError) { console.error(pc.red(`\n\nSession ended with error: ${eventState.lastError}`)) console.error(pc.yellow("Check if todos were completed before the error.")) - abortController.abort() - await eventProcessor.catch(() => {}) cleanup() - return 1 + process.exit(1) } const shouldExit = await checkCompletionConditions(ctx) if (shouldExit) { console.log(pc.green("\n\nAll tasks completed.")) - abortController.abort() - await eventProcessor.catch(() => {}) cleanup() - return 0 + process.exit(0) } } diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index 3836067..cb2f03e 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -57,7 +57,7 @@ export class BackgroundManager { private notifications: Map private client: OpencodeClient private directory: string - private pollingInterval?: Timer + private pollingInterval?: ReturnType constructor(ctx: PluginInput) { this.tasks = new Map() @@ -287,6 +287,7 @@ export class BackgroundManager { this.pollingInterval = setInterval(() => { this.pollRunningTasks() }, 2000) + this.pollingInterval.unref() } private stopPolling(): void { @@ -296,6 +297,12 @@ export class BackgroundManager { } } + cleanup(): void { + this.stopPolling() + this.tasks.clear() + this.notifications.clear() + } + private notifyParentSession(task: BackgroundTask): void { const duration = this.formatDuration(task.startedAt, task.completedAt)