fix: resolve GitHub Actions workflow hang after task completion
- Add process.exit(0) in runner.ts for immediate termination - Fix Timer type to ReturnType<typeof setInterval> 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)
This commit is contained in:
@@ -91,19 +91,15 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
if (eventState.mainSessionError) {
|
if (eventState.mainSessionError) {
|
||||||
console.error(pc.red(`\n\nSession ended with error: ${eventState.lastError}`))
|
console.error(pc.red(`\n\nSession ended with error: ${eventState.lastError}`))
|
||||||
console.error(pc.yellow("Check if todos were completed before the error."))
|
console.error(pc.yellow("Check if todos were completed before the error."))
|
||||||
abortController.abort()
|
|
||||||
await eventProcessor.catch(() => {})
|
|
||||||
cleanup()
|
cleanup()
|
||||||
return 1
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldExit = await checkCompletionConditions(ctx)
|
const shouldExit = await checkCompletionConditions(ctx)
|
||||||
if (shouldExit) {
|
if (shouldExit) {
|
||||||
console.log(pc.green("\n\nAll tasks completed."))
|
console.log(pc.green("\n\nAll tasks completed."))
|
||||||
abortController.abort()
|
|
||||||
await eventProcessor.catch(() => {})
|
|
||||||
cleanup()
|
cleanup()
|
||||||
return 0
|
process.exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export class BackgroundManager {
|
|||||||
private notifications: Map<string, BackgroundTask[]>
|
private notifications: Map<string, BackgroundTask[]>
|
||||||
private client: OpencodeClient
|
private client: OpencodeClient
|
||||||
private directory: string
|
private directory: string
|
||||||
private pollingInterval?: Timer
|
private pollingInterval?: ReturnType<typeof setInterval>
|
||||||
|
|
||||||
constructor(ctx: PluginInput) {
|
constructor(ctx: PluginInput) {
|
||||||
this.tasks = new Map()
|
this.tasks = new Map()
|
||||||
@@ -287,6 +287,7 @@ export class BackgroundManager {
|
|||||||
this.pollingInterval = setInterval(() => {
|
this.pollingInterval = setInterval(() => {
|
||||||
this.pollRunningTasks()
|
this.pollRunningTasks()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
|
this.pollingInterval.unref()
|
||||||
}
|
}
|
||||||
|
|
||||||
private stopPolling(): void {
|
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 {
|
private notifyParentSession(task: BackgroundTask): void {
|
||||||
const duration = this.formatDuration(task.startedAt, task.completedAt)
|
const duration = this.formatDuration(task.startedAt, task.completedAt)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user