mirror of
https://github.com/stablyai/orca.git
synced 2026-10-14 16:02:57 +00:00
fix: free runtime call queue after sync throw
This commit is contained in:
@@ -37,4 +37,16 @@ describe('runtime RPC call queue', () => {
|
||||
pending.shift()?.('background-2')
|
||||
await expect(background2).resolves.toBe('background-2')
|
||||
})
|
||||
|
||||
it('frees the queue slot when a runtime call throws synchronously', async () => {
|
||||
const queue = new RuntimeRpcCallQueuePool(1, 1)
|
||||
const first = queue.enqueue('web-runtime', 'status.get', () => {
|
||||
throw new Error('invalid stored runtime pairing')
|
||||
})
|
||||
|
||||
await expect(first).rejects.toThrow('invalid stored runtime pairing')
|
||||
|
||||
const second = queue.enqueue('web-runtime', 'status.get', async () => 'second')
|
||||
await expect(second).resolves.toBe('second')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -77,8 +77,10 @@ export class RuntimeRpcCallQueuePool {
|
||||
}
|
||||
// Why: runtime streams and worktree actions share transport capacity with
|
||||
// per-card status refreshes, so decorative calls must not stampede it.
|
||||
void call
|
||||
.run()
|
||||
// Invoke through the promise chain so sync validation errors free the
|
||||
// queue slot just like async transport failures.
|
||||
void Promise.resolve()
|
||||
.then(call.run)
|
||||
.then(call.resolve, call.reject)
|
||||
.finally(() => {
|
||||
queue.active = Math.max(0, queue.active - 1)
|
||||
|
||||
Reference in New Issue
Block a user