diff --git a/server/src/modules/run-dispatch/adapters/postgres.test.ts b/server/src/modules/run-dispatch/adapters/postgres.test.ts index 8a4e9a764f..7c50cca50e 100644 --- a/server/src/modules/run-dispatch/adapters/postgres.test.ts +++ b/server/src/modules/run-dispatch/adapters/postgres.test.ts @@ -319,8 +319,10 @@ describeEmbeddedPostgres("run-dispatch postgres adapter", () => { .set({ assigneeAgentId: newAssigneeAgentId }) .where(eq(issues.id, issueId)); }); - await locked; - return transaction; + // Await lock acquisition before starting the competing operation. Keep + // completion separate so setup does not wait for that operation to finish. + await Promise.race([locked, transaction]); + return { done: transaction }; } describe("evaluateScheduledRetryGate", () => { @@ -572,7 +574,7 @@ describeEmbeddedPostgres("run-dispatch postgres adapter", () => { contextSnapshot: { issueId, wakeReason: "issue_assigned" }, }); - const holderDone = reassignIssueAndLockRunOnceAConcurrentWaiterBlocks( + const { done: holderDone } = await reassignIssueAndLockRunOnceAConcurrentWaiterBlocks( issueId, runId, replacementAgentId, @@ -733,7 +735,7 @@ describeEmbeddedPostgres("run-dispatch postgres adapter", () => { // Acquire the issue row lock first and hold it until it observes a // concurrent `for update` waiter — the promote call below — proving // this is a real block, not a race the assertion got lucky on. - const holderDone = reassignIssueAndLockRunOnceAConcurrentWaiterBlocks( + const { done: holderDone } = await reassignIssueAndLockRunOnceAConcurrentWaiterBlocks( issueId, runId, newAgentId,