Skip to content

Commit d272d54

Browse files
Try catch resource tab deletion independently
1 parent 23cf0a6 commit d272d54

File tree

1 file changed

+12
-8
lines changed
  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs

1 file changed

+12
-8
lines changed

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,22 @@ export function ResourceTabs({
265265
setSelectedIds(new Set())
266266
anchorIdRef.current = null
267267
}
268-
// Serialize mutations so each onMutate sees the cache from the prior one;
269-
// calling .mutate() in a loop races the optimistic updates and the observer
270-
// discards all but the last in-flight mutation.
268+
// Serialize mutations so each onMutate sees the cache updated by the prior
269+
// one. Continue on individual failures so remaining removals still fire.
271270
const persistable = targets.filter((r) => !isEphemeralResource(r))
272271
if (persistable.length > 0) {
273272
void (async () => {
274273
for (const r of persistable) {
275-
await removeResource.mutateAsync({
276-
chatId,
277-
resourceType: r.type,
278-
resourceId: r.id,
279-
})
274+
try {
275+
await removeResource.mutateAsync({
276+
chatId,
277+
resourceType: r.type,
278+
resourceId: r.id,
279+
})
280+
} catch {
281+
// Individual failure — the mutation's onError already rolled back
282+
// this resource in cache. Remaining removals continue.
283+
}
280284
}
281285
})()
282286
}

0 commit comments

Comments
 (0)