Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(render-farm): drop every queued stitch of an ended job, promoted ones too
Richie McIlroya28b4fab0516
diff --git a/apps/render-farm/src/stitch.test.ts b/apps/render-farm/src/stitch.test.tsindex 6510d2f96..4043722e4 100644--- a/apps/render-farm/src/stitch.test.ts+++ b/apps/render-farm/src/stitch.test.ts@@ -244,16 +244,25 @@ describe("stitch limiter", () => {await blocking;});- test("cancelling a job drops its queued ahead work only", async () => {+ test("cancelling an ended job drops all its queued work, promoted too", async () => {const limiter = new StitchLimiter({ total: 1, ahead: 1, aheadPerJob: 1 });const busy = held();- const blocking = limiter.run("a", true, () => busy.done);+ const blocking = limiter.run("b", false, () => busy.done);const aheadWork = limiter.run("a", true, async () => "ran");+ const promoted = limiter.run("a", true, async () => "ran");+ limiter.promote("a");const assembly = limiter.run("a", false, async () => "assembled");+ const other = limiter.run("b", false, async () => "other");limiter.cancel("a");- await expect(aheadWork).rejects.toThrow("ended before its stitch ran");+ const settled = await Promise.allSettled([aheadWork, promoted, assembly]);+ for (const outcome of settled) {+ expect(outcome.status).toBe("rejected");+ expect(String((outcome as PromiseRejectedResult).reason)).toContain(+ "ended before its stitch ran",+ );+ }busy.release();await blocking;- expect(await assembly).toBe("assembled");+ expect(await other).toBe("other");});});diff --git a/apps/render-farm/src/stitch.ts b/apps/render-farm/src/stitch.tsindex fe340e439..5b23dc472 100644--- a/apps/render-farm/src/stitch.ts+++ b/apps/render-farm/src/stitch.ts@@ -186,10 +186,9 @@ export class StitchLimiter {this.pump();}+ /** Called once a job has ended: none of its queued work is still wanted. */cancel(job: string) {- const cancelled = this.waiting.filter(- (waiter) => waiter.job === job && waiter.ahead,- );+ const cancelled = this.waiting.filter((waiter) => waiter.job === job);this.waiting = this.waiting.filter((waiter) => !cancelled.includes(waiter));for (const waiter of cancelled) {waiter.cancel(new Error(`job ${job} ended before its stitch ran`));