Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): warn when the media server refuses a preverification run

Richie McIlroy3239218221b1
diff --git a/apps/web/__tests__/unit/desktop-recording-source.test.ts b/apps/web/__tests__/unit/desktop-recording-source.test.ts
index ba8b59918..eb8c7ac97 100644
--- a/apps/web/__tests__/unit/desktop-recording-source.test.ts
+++ b/apps/web/__tests__/unit/desktop-recording-source.test.ts
@@ -2976,6 +2976,32 @@ describe("decoding prepared fragments during the recording", () => {
expect(prepared).toHaveLength(2);
});
+ it("warns when the media server refuses a run without failing preparation", async () => {
+ mocks.env.mockReturnValue(mediaEnv);
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () =>
+ Response.json({ code: "SERVER_BUSY" }, { status: 503 }),
+ ),
+ );
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
+ const storage = listedStorage();
+ seedRecording(storage, 4, 0);
+ const prepared = await prepareDesktopRecordingSegments(
+ recording(),
+ [1, 2].map((index) => ({ track: "video" as const, index })),
+ async () => true,
+ );
+ expect(prepared).toHaveLength(2);
+ expect(warn).toHaveBeenCalledWith(
+ "[prepareDesktopRecordingSegments] Preverification skipped",
+ expect.objectContaining({
+ error: "Preverification request failed: HTTP 503",
+ }),
+ );
+ warn.mockRestore();
+ });
+
it("signs every saved run for the final verification on Cap's bucket only", async () => {
const storage = listedStorage();
storage.seed(
diff --git a/apps/web/lib/desktop-recording-source.ts b/apps/web/lib/desktop-recording-source.ts
index dbb70c3e0..20afbf8f7 100644
--- a/apps/web/lib/desktop-recording-source.ts
+++ b/apps/web/lib/desktop-recording-source.ts
@@ -1369,6 +1369,10 @@ async function requestSegmentPreverification(
},
);
await response.body?.cancel().catch(() => {});
+ if (!response.ok)
+ throw new Error(
+ `Preverification request failed: HTTP ${response.status}`,
+ );
}),
);
}