File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -292,12 +292,12 @@ export const cacheMiddleware: Middleware<DBCore> = {
292292 Object . freeze ( result [ i ] ) ;
293293 }
294294 Object . freeze ( result ) ;
295- } else {
296- // If not frozen, we need to clone the result to avoid user mutating the cache
297- // When we do this, user's must feel conformable with the fact that the result
298- // can be mutated deeply - user is not expected to have any respect for immutability.
299- res . result = deepClone ( result ) ;
300295 }
296+ // If not frozen (cache: 'cloned'), we do NOT clone here.
297+ // Since every cache read (including the initial one) will go through
298+ // the downstream .then() handler and perform a deepClone on read,
299+ // the original query results in the cache remain perfectly isolated
300+ // and we avoid a redundant double deepClone on the first query.
301301 return res ;
302302 } )
303303 . catch ( ( error ) => {
You can’t perform that action at this time.
0 commit comments