Skip to content

Commit

Permalink
fix: pendingCreates was not deleting when create errored
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Aug 31, 2024
1 parent 822613f commit e9fbf79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/sync-plugins/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,13 @@ export function syncedCrud<TRemote extends object, TLocal = TRemote, TAsOption e
await waitForSet(waitForSetParam as any, changes, itemValue, { type: 'create' });
}
const createObj = (await transformOut(itemValue as any, transform?.save)) as TRemote;
return createFn!(createObj, params).then((result) => {
pendingCreates.delete(itemKey);
return saveResult(itemKey, createObj, result as any, true);
});
return createFn!(createObj, params)
.then((result) => {
return saveResult(itemKey, createObj, result as any, true);
})
.finally(() => {
pendingCreates.delete(itemKey);
});
}),
...Array.from(updates).map(async ([itemKey, itemValue]) => {
if (waitForSetParam) {
Expand Down

0 comments on commit e9fbf79

Please sign in to comment.