fix: prevent exec approval resolve race

This commit is contained in:
Peter Steinberger
2026-01-22 06:42:36 +00:00
parent 862f34ade7
commit b573231cd1
2 changed files with 53 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ export function createExecApprovalHandlers(manager: ExecApprovalManager): Gatewa
sessionKey: p.sessionKey ?? null,
};
const record = manager.create(request, timeoutMs, explicitId);
const decisionPromise = manager.waitForDecision(record, timeoutMs);
context.broadcast(
"exec.approval.requested",
{
@@ -68,7 +69,7 @@ export function createExecApprovalHandlers(manager: ExecApprovalManager): Gatewa
},
{ dropIfSlow: true },
);
const decision = await manager.waitForDecision(record, timeoutMs);
const decision = await decisionPromise;
respond(
true,
{