Skip to content

Commit cf67175

Browse files
committed
fix(webapp): use prisma writer for cancelLostRaceRun's just-triggered run lookup
Same read-after-write pattern as the other lost-race re-reads: the run was just triggered on the writer milliseconds before, so a $replica.findFirst can return null due to replication lag. The null silently no-ops the cancellation and leaks an orphan run that no session will ever claim.
1 parent 554940d commit cf67175

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

apps/webapp/app/services/realtime/sessionRunManager.server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ async function cancelLostRaceRun(
362362
environment: AuthenticatedEnvironment
363363
): Promise<void> {
364364
const service = new CancelTaskRunService();
365-
// Resolve to a TaskRun reference — CancelTaskRunService takes the run
366-
// object, not the id. Read from the replica; the actual cancellation
367-
// write happens inside the service.
368-
const run = await $replica.taskRun.findFirst({ where: { id: runId } });
365+
// Read-after-write: the run was just triggered on the writer, so go
366+
// through `prisma`. A `$replica` miss here would silently no-op the
367+
// cancel and leak an orphan run that no session is going to claim.
368+
const run = await prisma.taskRun.findFirst({ where: { id: runId } });
369369
if (!run) return;
370370
await service.call(run, { reason: "Lost session-run claim race" });
371371
}

0 commit comments

Comments
 (0)