Open source CapCut alternative.
TypeScript
fix(cut): log why a tab export hands off to the worker
David Le1112684a66b2
diff --git a/site/src/cut/lib/exportStore.test.ts b/site/src/cut/lib/exportStore.test.tsindex d8461f1a..9ee35870 100644--- a/site/src/cut/lib/exportStore.test.ts+++ b/site/src/cut/lib/exportStore.test.ts@@ -119,3 +119,20 @@ test("hidden preparation stays hidden when the worker queues its job", async ()expect(useExports.getState().dismissed).toEqual(["queued"]);expect(useExports.getState().jobs[0].status).toBe("queued");});++test("a tab render that fails goes to the worker and says why in the console", async () => {+ const mode = spyOn(backend, "getBackend").mockReturnValue(exportBackend("cloud"));+ const probe = spyOn(exportRender, "canRenderInBrowser").mockResolvedValue(true);+ const failure = new DOMException("The operation failed because it would cause the application to exceed its storage quota.", "QuotaExceededError");+ const render = spyOn(exportClient, "runBrowserExport").mockRejectedValue(failure);+ const create = spyOn(exportClient, "createExportJob").mockResolvedValue("queued");+ const warn = spyOn(console, "warn").mockImplementation(() => {});+ restores.push(() => mode.mockRestore(), () => probe.mockRestore(), () => render.mockRestore(), () => create.mockRestore(), () => warn.mockRestore());+ feed([{ id: "queued", projectId: "project", residency: "cloud", status: "queued", progress: 0 }]);++ await useExports.getState().start("project", useEditor.getState(), {+ width: 1280, height: 720, ...EXPORT_PRESETS[0].settings,+ });+ expect(create).toHaveBeenCalled();+ expect(warn).toHaveBeenCalledWith(expect.stringContaining("worker"), failure);+});diff --git a/site/src/cut/lib/exportStore.ts b/site/src/cut/lib/exportStore.tsindex da46d02f..d11abbdd 100644--- a/site/src/cut/lib/exportStore.ts+++ b/site/src/cut/lib/exportStore.ts@@ -205,6 +205,9 @@ export const useExports = create<ExportsState>((set, get) => ({// is final: the worker sits behind the same gate.if (err instanceof DOMException && err.name === "AbortError") throw err;if (err instanceof ExportRefusedError) throw err;+ // The dock shows only the worker's row; the console keeps the+ // reason the tab gave up, or no one could find it.+ console.warn("The tab's render failed; the worker renders this export instead.", err);await renderOnWorker();}} else {