Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): stop cancelled exports before download

joshistoastfb0db264f3da
diff --git a/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.test.ts b/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.test.ts
index 9079beceea..4ec4129cf4 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.test.ts
@@ -250,6 +250,27 @@ describe('executeInvkExport', () => {
expect(download).not.toHaveBeenCalled();
});
+ it('rejects rather than downloading when cancellation occurs during packing', async () => {
+ const download = vi.fn();
+ const controller = new AbortController();
+
+ await expect(
+ executeInvkExport(planInvkExport(planInput), {
+ download,
+ fetchImageBytes: (imageName) => Promise.resolve(bytesFor(imageName)),
+ fetchImageThumbnail: () => Promise.resolve(null),
+ onProgress: ({ phase }) => {
+ if (phase === 'packing') {
+ controller.abort();
+ }
+ },
+ signal: controller.signal,
+ })
+ ).rejects.toMatchObject({ name: 'AbortError' });
+
+ expect(download).not.toHaveBeenCalled();
+ });
+
it('still treats an unservable asset as a skip, not a cancellation', async () => {
const download = vi.fn();
const result = await executeInvkExport(planInvkExport(planInput), {
diff --git a/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.ts b/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.ts
index c5557d653d..dafbf6cd62 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/invk/exportProject.ts
@@ -193,6 +193,8 @@ export const executeInvkExport = async (plan: InvkExportPlan, deps: InvkExportDe
const blob = await writeArchive(entries);
+ deps.signal?.throwIfAborted();
+
deps.download(blob, plan.fileName);
return { bundledImageCount, bundledVideoCount, missingAssetNames: missingAssetNames.sort() };