Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 2004d9e

Browse files
authored
fix: should not return failed code on model already loaded (#913)
1 parent 5caef68 commit 2004d9e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cortex-js/src/usecases/models/models.usecases.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export class ModelsUsecases {
197197

198198
return engine
199199
.loadModel(model, loadModelSettings)
200+
.catch((e) => {
201+
// Skip model already loaded error
202+
if (e.code === AxiosError.ERR_BAD_REQUEST) return;
203+
else throw e;
204+
})
200205
.then(() => {
201206
this.activeModelStatuses[modelId] = {
202207
model: modelId,
@@ -226,13 +231,6 @@ export class ModelsUsecases {
226231
metadata: {},
227232
};
228233
this.eventEmitter.emit('model.event', modelEvent);
229-
if (e.code === AxiosError.ERR_BAD_REQUEST) {
230-
loadingModelSpinner.succeed('Model loaded');
231-
return {
232-
message: 'Model already loaded',
233-
modelId,
234-
};
235-
}
236234
loadingModelSpinner.fail('Model loading failed');
237235
await this.telemetryUseCases.createCrashReport(
238236
e,

0 commit comments

Comments
 (0)