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): guard stale-scope error toasts

Josh Corbett99290bc333cf
diff --git a/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx b/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx
index 95ecb3b734..dd4f2d558d 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx
@@ -80,9 +80,22 @@ export const AddModelsView = () => {
useMountEffect(() => {
ensureStartersLoaded();
+
+ const owner = captureAccountScope();
+ let isMounted = true;
+
ensureExternalProvidersLoaded().catch((error: unknown) => {
- notify.error(t('models.externalProviderKeysUnavailable'), error instanceof Error ? error.message : String(error));
+ if (isMounted && isAccountScopeCurrent(owner)) {
+ notify.error(
+ t('models.externalProviderKeysUnavailable'),
+ error instanceof Error ? error.message : String(error)
+ );
+ }
});
+
+ return () => {
+ isMounted = false;
+ };
});
const trimmed = query.trim();
diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx
index f6ece4a28c..6b3b7dbe78 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx
@@ -44,12 +44,17 @@ const RelatedModelsForModel = ({ model, onError }: RelatedModelsSectionProps) =>
useMountEffect(() => {
const owner = captureAccountScope();
+ let isMounted = true;
refreshRelatedModelKeys(model.key).catch((error: unknown) => {
- if (isAccountScopeCurrent(owner)) {
+ if (isMounted && isAccountScopeCurrent(owner)) {
onError(error instanceof Error ? error.message : t('models.failedToLoadRelatedModels'));
}
});
+
+ return () => {
+ isMounted = false;
+ };
});
const relatedModels = useMemo(() => {