Commit d66152a
fix: align multiGet cache hit check with cache.hasCacheForKey
Inside OnyxUtils.multiGet, the cached-value path was guarded by a truthy
check (`if (cacheValue)`), which treats cached falsy values (0, '',
false, null) as cache misses. Those keys fell through to
missingKeys → Storage.multiGet → cache.merge(temp), which would
overwrite the warm cached value with whatever stale value sat in
storage.
This mattered most after the new perf hybrid pre-warm in
mergeCollectionWithPatches started routing cold-cache merges through
multiGet — the outer check (`!cache.hasCacheForKey(key)`) and the inner
check disagreed for falsy values. Concrete case: `Onyx.set('coll_1', 0)`
updates cache to `0` but the storage write is still in flight; a
mergeCollection over the same collection key would re-fetch `coll_1`
from storage and clobber the cached `0`.
Aligns the inner check with hasCacheForKey so both sides agree, and
adds a regression test that seeds cache with `0` and asserts multiGet
returns it without touching Storage.multiGet / Storage.getItem.
Addresses fabioh8010's review on PR #5
(#5 (review)).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d02382f commit d66152a
2 files changed
Lines changed: 43 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
352 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
353 | 355 | | |
354 | 356 | | |
355 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
1094 | 1132 | | |
1095 | 1133 | | |
1096 | 1134 | | |
| |||
0 commit comments