fix: race condition between model stop and engine update

This commit is contained in:
Louis 2025-01-16 16:28:05 +07:00
parent 713926e68c
commit 589fc53030
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2

View File

@ -105,8 +105,8 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
}, [defaultEngineVariant])
const handleEngineUpdate = useCallback(
(event: { id: string; type: DownloadEvent; percent: number }) => {
stopModel()
async (event: { id: string; type: DownloadEvent; percent: number }) => {
await stopModel().catch(console.info)
mutateInstalledEngines()
mutateDefaultEngineVariant()
// Backward compatible support - cortex.cpp returns full variant file name
@ -156,8 +156,8 @@ const LocalEngineSettings = ({ engine }: { engine: InferenceEngine }) => {
}
}, [handleEngineUpdate])
const handleChangeVariant = (e: string) => {
stopModel()
const handleChangeVariant = async (e: string) => {
await stopModel().catch(console.info)
setSelectedVariants(e)
setDefaultEngineVariant(engine, {
variant: e,