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(ui): retry starter and install-queue loads after a failed first fetch

joshistoast9887e7fab3b0
diff --git a/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts b/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts
index c319fcde1c..16bd4e3b96 100644
--- a/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts
+++ b/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts
@@ -149,6 +149,28 @@ describe('model install event interpretation', () => {
expect(store.getInstallsSnapshot().jobs).toEqual([{ id: 1, source: 'org/model', status: 'completed' }]);
});
+ it('retries a failed load on the next ensure instead of sticking in error', async () => {
+ dependencies.listModelInstalls
+ .mockReset()
+ .mockRejectedValueOnce(new Error('outage'))
+ .mockResolvedValueOnce([{ id: 1, source: 'org/model', status: 'waiting' }]);
+
+ const store = await import('./installsStore');
+
+ store.ensureInstallsLoaded();
+ await vi.advanceTimersByTimeAsync(0);
+ expect(store.getInstallsSnapshot().status).toBe('error');
+
+ store.ensureInstallsLoaded();
+ await vi.advanceTimersByTimeAsync(0);
+ expect(store.getInstallsSnapshot()).toEqual({
+ error: null,
+ jobs: [{ id: 1, source: 'org/model', status: 'waiting' }],
+ status: 'loaded',
+ });
+ expect(dependencies.listModelInstalls).toHaveBeenCalledTimes(2);
+ });
+
it('ignores socket events owned by an expired account scope', async () => {
const store = await import('./installsStore');
const { accountLifecycle } = await import('@platform/state/accountLifecycle');
diff --git a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts b/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
index f22abf031a..34505fb61b 100644
--- a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
+++ b/invokeai/frontend/webv2/src/features/models/data/installsStore.ts
@@ -133,8 +133,11 @@ export const refreshInstalls = (owner: AccountScope = captureAccountScope()): Pr
});
});
+/** Fetch on first use or retry after an error, so one failed load never sticks. */
export const ensureInstallsLoaded = (): void => {
- if (store.getSnapshot().status === 'idle') {
+ const { status } = store.getSnapshot();
+
+ if (status === 'idle' || status === 'error') {
void refreshInstalls();
}
};
diff --git a/invokeai/frontend/webv2/src/features/models/data/startersStore.test.ts b/invokeai/frontend/webv2/src/features/models/data/startersStore.test.ts
index a0b64de937..475e3724a8 100644
--- a/invokeai/frontend/webv2/src/features/models/data/startersStore.test.ts
+++ b/invokeai/frontend/webv2/src/features/models/data/startersStore.test.ts
@@ -42,6 +42,22 @@ describe('starters store', () => {
expect(api.getStarterModels).toHaveBeenCalledTimes(1);
});
+ it('retries a failed load on the next ensure instead of sticking in error', async () => {
+ api.getStarterModels.mockRejectedValueOnce(new Error('outage')).mockResolvedValueOnce(response);
+ const store = await import('./startersStore');
+
+ store.ensureStartersLoaded();
+ await vi.waitFor(() => {
+ expect(store.getStartersSnapshot().status).toBe('error');
+ });
+
+ store.ensureStartersLoaded();
+ await vi.waitFor(() => {
+ expect(store.getStartersSnapshot()).toMatchObject({ response, status: 'loaded' });
+ });
+ expect(api.getStarterModels).toHaveBeenCalledTimes(2);
+ });
+
it('clears the catalog on account switch', async () => {
const account = await import('@platform/state/accountLifecycle');
account.accountLifecycle.activate('user-a');
diff --git a/invokeai/frontend/webv2/src/features/models/data/startersStore.ts b/invokeai/frontend/webv2/src/features/models/data/startersStore.ts
index 1f070cfae8..34e499cc71 100644
--- a/invokeai/frontend/webv2/src/features/models/data/startersStore.ts
+++ b/invokeai/frontend/webv2/src/features/models/data/startersStore.ts
@@ -60,8 +60,11 @@ export const refreshStarters = (): Promise<void> =>
});
});
+/** Fetch on first use or retry after an error, so one failed load never sticks. */
export const ensureStartersLoaded = (): void => {
- if (store.getSnapshot().status === 'idle') {
+ const { status } = store.getSnapshot();
+
+ if (status === 'idle' || status === 'error') {
void refreshStarters();
}
};