mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 08:03:12 +00:00
refactor: simplify provider snapshot timeout handling
This commit is contained in:
@@ -143,25 +143,21 @@ export class OrcaRuntimeWithSerializeTerminalBufferFromAvailableState extends Or
|
||||
}
|
||||
})
|
||||
}
|
||||
if (acquisition.timedOut) {
|
||||
return null
|
||||
}
|
||||
if (typeof wait.timeoutMs !== 'number') {
|
||||
return acquisition.promise
|
||||
}
|
||||
const result = await withTimeout<
|
||||
{ settled: true; value: PtyProviderBufferSnapshot | null } | { settled: false }
|
||||
>(
|
||||
acquisition.promise.then((value) => ({ settled: true as const, value })),
|
||||
// Undefined marks a timeout; null is a settled provider with no snapshot.
|
||||
const result = await withTimeout<PtyProviderBufferSnapshot | null | undefined>(
|
||||
acquisition.promise,
|
||||
wait.timeoutMs,
|
||||
{ settled: false as const }
|
||||
undefined
|
||||
)
|
||||
if (!result.settled) {
|
||||
if (result === undefined) {
|
||||
if (wait.retireOnTimeout) {
|
||||
acquisition.timedOut = true
|
||||
}
|
||||
return null
|
||||
}
|
||||
return result.value
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user