Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vcs-sync): clean cache on api error #6887

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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