cli/mini: fix run failure handling (#35539)

This commit is contained in:
Simon Klee
2026-07-06 12:34:44 +02:00
committed by GitHub
parent b2cf7a2953
commit c45256c025
13 changed files with 152 additions and 50 deletions
+9 -3
View File
@@ -132,8 +132,14 @@ export async function runNonInteractivePrompt(input: Input) {
const consume = async () => {
while (!controller.signal.aborted) {
const next = await stream.next()
if (next.done) throw new Error("Event stream disconnected during prompt execution")
const next = await stream.next().catch((error) => {
if (!emittedError) throw error
return { done: true as const, value: undefined }
})
if (next.done) {
if (emittedError) return
throw new Error("Event stream disconnected during prompt execution")
}
const event = next.value
if (event.type === "permission.v2.asked" && submitted && event.data.sessionID === input.sessionID) {
@@ -416,7 +422,7 @@ export async function runNonInteractivePrompt(input: Input) {
}
controller.abort()
await completed?.catch(() => {})
if (interrupted) return undefined
if (interrupted || emittedError) return undefined
throw error
})
admission = undefined