From ebb8d632c400a66816bb3064d89875eb3495efc3 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:04:09 +0100 Subject: [PATCH] Fix for "random" crash on creation --- frontend/src/layouts/AppLayout/AppLayout.tsx | 3 +++ frontend/src/pages/org/[id]/overview/index.tsx | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 1cda2c6d7d..84dc0f480a 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -238,6 +238,9 @@ export const AppLayout = ({ children }: LayoutProps) => { projectId: newProjectId }); } + + // eslint-disable-next-line no-promise-executor-return -- We do this because the function returns too fast, which sometimes causes an error when the user is redirected. + await new Promise((resolve) => setTimeout(resolve, 2_000)); createNotification({ text: "Workspace created", type: "success" }); handlePopUpClose("addNewWs"); diff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsx index 1b574611cd..8a703b3dcc 100644 --- a/frontend/src/pages/org/[id]/overview/index.tsx +++ b/frontend/src/pages/org/[id]/overview/index.tsx @@ -520,8 +520,11 @@ const OrganizationPage = withPermission( }); } - createNotification({ text: "Workspace created", type: "success" }); + // eslint-disable-next-line no-promise-executor-return -- We do this because the function returns too fast, which sometimes causes an error when the user is redirected. + await new Promise((resolve) => setTimeout(resolve, 2_000)); + handlePopUpClose("addNewWs"); + createNotification({ text: "Workspace created", type: "success" }); router.push(`/project/${newProjectId}/secrets/overview`); } catch (err) { console.error(err);