Skip to content

Commit 0e17950

Browse files
fix(ui): race condition when setting hf token and downloading model
I ran into a race condition where I set a HF token and it was valid, but somehow this error toast still appeared. The conditional feel through to an assertion that we never expected to get to, which crashed the UI. Handled the unexpected case gracefully now.
1 parent b0cfdc9 commit 0e17950

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

invokeai/frontend/web/src/services/events/onModelInstallError.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,21 @@ const HFUnauthorizedToastDescription = () => {
173173
if (data === 'unknown') {
174174
return (
175175
<Text fontSize="md">
176-
{t('modelManager.hfTokenUnableToErrorMessage')}{' '}
176+
{t('modelManager.hfTokenUnableToVerifyErrorMessage')}{' '}
177177
<Button onClick={onClick} variant="link" color="base.50" flexGrow={0}>
178178
{t('modelManager.modelManager')}.
179179
</Button>
180180
</Text>
181181
);
182182
}
183183

184-
// data === 'valid' - should never happen!
185-
assert(false, 'Unexpected valid HF token with unauthorized error');
184+
// data === 'valid' - user may have a token but not authorized for model?
185+
return (
186+
<Text fontSize="md">
187+
{t('modelManager.hfTokenForbiddenErrorMessage')}{' '}
188+
<Button onClick={onClick} variant="link" color="base.50" flexGrow={0}>
189+
{t('modelManager.modelManager')}.
190+
</Button>
191+
</Text>
192+
);
186193
};

0 commit comments

Comments
 (0)