Skip to content

Commit 9085b9e

Browse files
committed
fix(webapp): handle a nullish worker queue when deriving a run's region
Synthetic run snapshots (the mollifier buffer path) can carry a null or undefined workerQueue, which their TaskRun casts hide from the type checker. `baseWorkerQueue` now passes a nullish worker queue straight through instead of calling `.indexOf` on it, so the replay loader and replay service no longer throw when replaying a buffered run.
1 parent debd380 commit 9085b9e

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

apps/webapp/app/runEngine/concerns/workerQueueSplit.server.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ export const SCHEDULED_WORKER_QUEUE_SUFFIX = ":scheduled";
1919
* region is everything before the first `:`. Use this wherever a worker queue is
2020
* read as a region — for display, filtering, or as a region override — so
2121
* scheduled-split runs group under their real region instead of a phantom one.
22-
* Idempotent; returns the input unchanged when there's no suffix.
22+
* Idempotent; returns the input unchanged when there's no suffix. A nullish
23+
* worker queue (e.g. from a synthetic run snapshot) passes straight through.
2324
*/
24-
export function baseWorkerQueue(workerQueue: string): string {
25+
export function baseWorkerQueue(workerQueue: string): string;
26+
export function baseWorkerQueue(workerQueue: string | null | undefined): string | null | undefined;
27+
export function baseWorkerQueue(workerQueue: string | null | undefined): string | null | undefined {
28+
if (workerQueue == null) {
29+
return workerQueue;
30+
}
31+
2532
const colon = workerQueue.indexOf(":");
2633
return colon === -1 ? workerQueue : workerQueue.slice(0, colon);
2734
}

apps/webapp/test/workerQueueSplit.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ describe("baseWorkerQueue", () => {
125125
expect(baseWorkerQueue("")).toBe("");
126126
});
127127

128+
it("passes a nullish worker queue straight through (synthetic run snapshots)", () => {
129+
expect(baseWorkerQueue(null)).toBeNull();
130+
expect(baseWorkerQueue(undefined)).toBeUndefined();
131+
});
132+
128133
it("round-trips with workerQueueForRun: the split queue strips back to the region it came from", () => {
129134
const enqueued = workerQueueForRun({
130135
workerQueue: region,

0 commit comments

Comments
 (0)