Skip to content

Commit f1351bb

Browse files
committed
test: reconcile guards with base-PR production changes
- cancelRun / idempotencyReset NEW-ksuid cases: use a run-ops-shaped friendlyId so the by-friendlyId read routes to NEW single-store (the fan-out that masked the fake LEGACY-classifying friendlyId is gone; a real NEW run's friendlyId classifies NEW). - routesBatchGet realtime.v1.batches case: assert the loader now recovers a stale-on-replica batch via the owning-primary re-read (reaches streamBatch, 200) instead of a resource-gate 404.
1 parent d1f1a85 commit f1351bb

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

apps/webapp/test/routesBatchGetReplicaLag.guard.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,11 @@ describe("routes-batch-get callers under a lagging replica", () => {
274274
}
275275
);
276276

277-
// ── realtime.v1.batches loader — findBatchTaskRunByFriendlyId (REPLICA) ─────────────
277+
// ── realtime.v1.batches loader — replica miss recovered by the owning-primary re-read ─────────────
278+
// The realtime loader re-reads the owning primary on a replica miss (the ShapeStream consumer ignores
279+
// x-should-retry, so a 404 here would strand), so a stale-on-replica batch reaches streamBatch.
278280
heteroRunOpsPostgresTest(
279-
"realtime.v1.batches loader: stale-null returns a retryable 404 at the resource gate before streamBatch",
281+
"realtime.v1.batches loader: a batch stale on the replica is recovered via the owning-primary re-read (reaches streamBatch, no 404)",
280282
async ({ prisma14, prisma17 }) => {
281283
const { router, legacyStore, legacyReplica } = buildLaggingRouter(prisma14, prisma17);
282284
const suffix = `bget_rt_${seq++}`;
@@ -299,10 +301,11 @@ describe("routes-batch-get callers under a lagging replica", () => {
299301
context: {} as never,
300302
})) as Response;
301303

304+
// Replica was consulted first (the miss)…
302305
expect(legacyReplica.wasHit("batchTaskRun")).toBe(true);
303-
// 404 at the resource gate — the subscription never starts (streamBatch would return a 200 body).
304-
expect(res.status).toBe(404);
305-
expect(res.headers.get("x-should-retry")).toBe("true");
306+
// …then the owning-primary re-read found the live batch, so the subscription starts (streamBatch
307+
// returns 200) instead of a resource-gate 404.
308+
expect(res.status).toBe(200);
306309
}
307310
);
308311

internal-packages/run-store/src/runOpsStore.cancelRunReadAfterWrite.replicaLag.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ describe("run-ops split — cancel-route run lookup vs. a lagging replica (read-
192192

193193
const seed = await seedEnvironment(prisma17, "dedicated", "cancel_new");
194194
const runId = NEW_RUN_ID; // v1 body → NEW
195-
const friendlyId = "run_cancel_new";
195+
// friendlyId classifies identically to the id, so a NEW run's friendlyId must be run-ops-shaped
196+
// for the by-friendlyId read to route to NEW (single-store; no cross-store fan-out).
197+
const friendlyId = `run_${generateRunOpsId()}`;
196198
await newStore.createRun(
197199
buildCreateRunInput({
198200
runId,

internal-packages/run-store/src/runOpsStore.idempotencyResetReadView.replicaLag.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ describe("run-ops split — idempotency-key reset source-run lookup vs. a laggin
194194

195195
const seed = await seedEnvironment(prisma17, "dedicated", "idem_reset_new");
196196
const runId = NEW_RUN_ID; // v1 body → NEW
197-
const friendlyId = "run_idem_reset_new";
197+
// A NEW run's friendlyId must be run-ops-shaped so the by-friendlyId read routes to NEW
198+
// (single-store; friendlyId classifies identically to the id).
199+
const friendlyId = `run_${generateRunOpsId()}`;
198200
const idempotencyKey = "user-supplied-key-new";
199201
await newStore.createRun(
200202
buildCreateRunInput({

0 commit comments

Comments
 (0)