Clear race timers so waits never outlive the operation
This commit is contained in:
1 parent
fccf5fc6d2
commit
a47bcb03ab
1 file changed
+4
-1
@@ -66,7 +66,10 @@ export function apply(ctx, config = {}) {
|
||||
|
||||
// At the end of a turn: deliver late advice; a blocker forces one more step.
|
||||
disposers.push(agent.ctx.on('agent/turn-stopping', async ({ signal }) => {
|
||||
if (st.pending) await Promise.race([st.pending, new Promise((r) => setTimeout(r, cfg.blocking ? cfg.timeoutMs : 4000))])
|
||||
if (st.pending) {
|
||||
let t
|
||||
await Promise.race([st.pending, new Promise((r) => { t = setTimeout(r, cfg.blocking ? cfg.timeoutMs : 4000) })]).finally(() => clearTimeout(t))
|
||||
}
|
||||
const notes = st.queue.splice(0)
|
||||
const block = notes.find((n) => n.verdict === 'blocker')
|
||||
if (block && !signal?.aborted) {
|
||||
|
||||
Reference in new issue
Block a user