Skip to content

Commit e41f017

Browse files
committed
Resolves #2011
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.
1 parent 7798fdf commit e41f017

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/live-query/cache/cache-middleware.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ export const cacheMiddleware: Middleware<DBCore> = {
149149
if (
150150
primKey.outbound || // Non-inbound tables are harded to apply optimistic updates on because we can't know primary key of results
151151
trans.db._options.cache === 'disabled' || // User has opted-out from caching
152-
trans.explicit // It's an explicit write transaction being made. Don't affect cache until transaction commits.
152+
trans.explicit || // It's an explicit write transaction being made. Don't affect cache until transaction commits.
153+
trans.idbtrans.mode !== 'readwrite' // We only handle 'readwrite' in our transaction override. 'versionchange' transactions don't use cache (from populate or upgraders).
153154
) {
154155
// Just forward the request to the core.
155156
return downTable.mutate(req);

0 commit comments

Comments
 (0)