fix(opencode): await run event loop (#31389)

This commit is contained in:
Aiden Cline 2026-06-08 12:47:39 -05:00 committed by GitHub
parent f43209bb8c
commit 0a7cb20e66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -762,10 +762,15 @@ export const RunCommand = effectCmd({
if (!args.interactive) {
const events = await client.event.subscribe()
loop(client, events).catch((e) => {
const completed = loop(client, events).catch((e) => {
console.error(e)
process.exit(1)
process.exitCode = 1
})
async function finish() {
if (args.attach) return
const error = await completed
if (error) process.exitCode = 1
}
if (args.command) {
const result = await client.session.command({
@ -779,7 +784,9 @@ export const RunCommand = effectCmd({
if (result.error) {
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
process.exitCode = 1
return
}
await finish()
return
}
@ -794,7 +801,9 @@ export const RunCommand = effectCmd({
if (result.error) {
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
process.exitCode = 1
return
}
await finish()
return
}