From 13ee014496ab2ef287fe67a5c2ac440bd828f9ad Mon Sep 17 00:00:00 2001 From: James Gatz Date: Thu, 30 Nov 2023 17:30:01 +0100 Subject: [PATCH] fix(vcs-sync): clean cache on api error (#6887) --- packages/insomnia/src/ui/routes/remote-collections.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/insomnia/src/ui/routes/remote-collections.tsx b/packages/insomnia/src/ui/routes/remote-collections.tsx index 75ea82ec188..ca4413aa1d5 100644 --- a/packages/insomnia/src/ui/routes/remote-collections.tsx +++ b/packages/insomnia/src/ui/routes/remote-collections.tsx @@ -182,11 +182,10 @@ const remoteCompareCache: Record = {} const remoteBackendProjectsCache: Record = {}; export const syncDataAction: ActionFunction = async ({ params }) => { + const { projectId, workspaceId } = params; + invariant(typeof projectId === 'string', 'Project Id is required'); + invariant(typeof workspaceId === 'string', 'Workspace Id is required'); try { - const { projectId, workspaceId } = params; - invariant(typeof projectId === 'string', 'Project Id is required'); - invariant(typeof workspaceId === 'string', 'Workspace Id is required'); - const project = await models.project.getById(projectId); invariant(project, 'Project not found'); invariant(project.remoteId, 'Project is not remote'); @@ -210,6 +209,9 @@ export const syncDataAction: ActionFunction = async ({ params }) => { }; } catch (e) { const errorMessage = e instanceof Error ? e.message : 'Unknown error while syncing data.'; + delete remoteBranchesCache[workspaceId]; + delete remoteCompareCache[workspaceId]; + delete remoteBackendProjectsCache[workspaceId]; return { error: errorMessage, };