Skip to content

Commit 62247f4

Browse files
committed
chore(run-store,run-engine): fix formatting and bind forwarded prisma methods in test proxies
oxfmt the wrapped method signature, and make the lagging-replica test proxies bind any forwarded method to the real client. Prisma delegates are proxy-based and not pre-bound, so an unbound forwarded method could trip a this/private-field brand check when called.
1 parent fee35d5 commit 62247f4

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

internal-packages/run-engine/src/engine/tests/startRunAttemptReadResidency.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,17 @@ function laggingLockReplica<C extends RunOpsPrismaClient>(
137137
return row ? { ...row, lockedById: null } : row;
138138
};
139139
}
140-
return (target as any)[prop];
140+
// Bind forwarded methods to the real client: Prisma delegates are proxy-based and not
141+
// pre-bound, so an unbound method would trip a this/private-field brand check when called.
142+
const forwarded = (target as any)[prop];
143+
return typeof forwarded === "function" ? forwarded.bind(target) : forwarded;
141144
},
142145
});
143146
const client = new Proxy(real as any, {
144147
get(target, prop) {
145-
return prop === "taskRun" ? laggingTaskRun : (target as any)[prop];
148+
if (prop === "taskRun") return laggingTaskRun;
149+
const forwarded = (target as any)[prop];
150+
return typeof forwarded === "function" ? forwarded.bind(target) : forwarded;
146151
},
147152
}) as C;
148153
return { client, wasHit: () => hit };

internal-packages/run-engine/src/engine/tests/waitpointReplicaLag.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ function laggingPendingReplica<C extends RunOpsPrismaClient>(
199199
return (target as any).$queryRaw(strings, ...values);
200200
};
201201
}
202-
return (target as any)[prop];
202+
// Bind forwarded methods to the real client (Prisma delegates are proxy-based, not pre-bound).
203+
const forwarded = (target as any)[prop];
204+
return typeof forwarded === "function" ? forwarded.bind(target) : forwarded;
203205
},
204206
}) as C;
205207
return { client, wasHit: () => hit };

internal-packages/run-store/src/runOpsStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,10 @@ export class RoutingRunStore implements RunStore {
833833
// Snapshot ids are cuids (they always classify LEGACY), and a snapshot's CompletedWaitpoint join
834834
// co-locates with its run, which may live on either store, so fan out to BOTH and merge (like
835835
// findWaitpointCompletedSnapshotIds) rather than route by the un-classifiable snapshot id.
836-
async findSnapshotCompletedWaitpointIds(snapshotId: string, client?: ReadClient): Promise<string[]> {
836+
async findSnapshotCompletedWaitpointIds(
837+
snapshotId: string,
838+
client?: ReadClient
839+
): Promise<string[]> {
837840
const [fromNew, fromLegacy] = await Promise.all([
838841
this.#new.findSnapshotCompletedWaitpointIds(
839842
snapshotId,

0 commit comments

Comments
 (0)