From ed3e779d22f6682e1f9d934f7dedf7bd705c8f24 Mon Sep 17 00:00:00 2001 From: jialin Date: Sun, 14 Jun 2026 19:10:23 +0800 Subject: [PATCH] fix: do not trigger setInitialized in catch when error occured --- .../instances/components/add-modal.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/gpu-service/instances/components/add-modal.tsx b/src/pages/gpu-service/instances/components/add-modal.tsx index 4d883199..76a07c16 100644 --- a/src/pages/gpu-service/instances/components/add-modal.tsx +++ b/src/pages/gpu-service/instances/components/add-modal.tsx @@ -312,20 +312,20 @@ const AddModal: React.FC = ({ // The query hook cancels any in-flight request on each new call, so when // this runs twice in quick succession (drawer open, then the scope // picker settling on its default) the latest scope's result wins. - const loadCreateResources = (orgId?: number | null) => { + const loadCreateResources = async (orgId?: number | null) => { const session = ++sessionRef.current; try { - Promise.all([fetchData({ page: -1 }), fetchTemplates({ page: -1 })]).then( - ([instanceResItems, templatesRes]) => { - if (sessionRef.current !== session) return; - applyAutoSelection( - instanceResItems || [], - templatesRes?.items || [], - orgId - ); - setInitialized(true); - } + const [instanceResItems, templatesRes] = await Promise.all([ + fetchData({ page: -1 }), + fetchTemplates({ page: -1 }) + ]); + if (sessionRef.current !== session) return; + applyAutoSelection( + instanceResItems || [], + templatesRes?.items || [], + orgId ); + setInitialized(true); } catch (error) { setInitialized(true); }