Skip to content

Commit

Permalink
Resolves #2011
Browse files Browse the repository at this point in the history
Another bug than 2012: on.on('populate') executes within 'versionchange' transaction and not normal 'readwrite' transaction.
The result was that our "mutate" override added the optimistic updates but the "transaction" override didn't follow up on these optimistic updates because it only follows up on "readwrite" transactions so it left them hanging there forever.
  • Loading branch information
dfahlander committed Jul 17, 2024
1 parent 7798fdf commit d227932
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/live-query/cache/cache-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ export const cacheMiddleware: Middleware<DBCore> = {
if (
primKey.outbound || // Non-inbound tables are harded to apply optimistic updates on because we can't know primary key of results
trans.db._options.cache === 'disabled' || // User has opted-out from caching
trans.explicit // It's an explicit write transaction being made. Don't affect cache until transaction commits.
trans.explicit || // It's an explicit write transaction being made. Don't affect cache until transaction commits.
trans.idbtrans.mode !== 'readwrite' // We only handle 'readwrite' in our transaction override. 'versionchange' transactions don't use cache (from populate or upgraders).
) {
// Just forward the request to the core.
return downTable.mutate(req);
Expand Down

0 comments on commit d227932

Please sign in to comment.