fix(opencode): await run event loop (#31389)
This commit is contained in:
@@ -762,10 +762,15 @@ export const RunCommand = effectCmd({
|
|||||||
|
|
||||||
if (!args.interactive) {
|
if (!args.interactive) {
|
||||||
const events = await client.event.subscribe()
|
const events = await client.event.subscribe()
|
||||||
loop(client, events).catch((e) => {
|
const completed = loop(client, events).catch((e) => {
|
||||||
console.error(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) {
|
if (args.command) {
|
||||||
const result = await client.session.command({
|
const result = await client.session.command({
|
||||||
@@ -779,7 +784,9 @@ export const RunCommand = effectCmd({
|
|||||||
if (result.error) {
|
if (result.error) {
|
||||||
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
||||||
process.exitCode = 1
|
process.exitCode = 1
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
await finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,7 +801,9 @@ export const RunCommand = effectCmd({
|
|||||||
if (result.error) {
|
if (result.error) {
|
||||||
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
||||||
process.exitCode = 1
|
process.exitCode = 1
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
await finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user