Skip to content

Commit

Permalink
fix(vcs-sync): clean cache on api error (#6887)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatzjames authored Nov 30, 2023
1 parent fc7ccf3 commit 13ee014
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/insomnia/src/ui/routes/remote-collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,10 @@ const remoteCompareCache: Record<string, { ahead: number; behind: number }> = {}
const remoteBackendProjectsCache: Record<string, BackendProject[]> = {};

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');
Expand All @@ -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,
};
Expand Down

0 comments on commit 13ee014

Please sign in to comment.