Commit 7fb447d
fix: preserve cache-first merge when multiGet pre-warm rejects
The new hybrid pre-warm in mergeCollectionWithPatches replaced
`Promise.all(existingKeys.map(get))` with `multiGet(existingKeys)` on
the slow path. The two have different failure semantics:
- get() catches storage read errors per-key and resolves with undefined
(see Logger.logInfo catch at the bottom of get()).
- multiGet() has no .catch, so Storage.multiGet rejections propagate
all the way up.
In the cold-key path this meant a transient IndexedDB read error
rejected before cache.merge() and keysChanged() ran — subscribers
missed the in-memory merge and the outer Onyx.mergeCollection / Onyx.update
promise rejected, regressing the cache-first invariant established
in PR #787 (#787).
Adds a .catch at the call site that swallows the rejection (logging
via Logger.logInfo for visibility) so cache.merge + keysChanged still
fire when pre-warm reads fail. Doesn't modify multiGet itself —
other callers may legitimately depend on rejection visibility.
Adds a regression test that mocks Storage.multiGet to reject on the
pre-warm read and asserts:
1. Onyx.mergeCollection resolves (doesn't reject up to caller).
2. The waitForCollectionCallback subscriber sees the merged delta.
Confirmed: test fails on pre-fix code with "Received: [Error:
Transient IndexedDB read error]" on `expect(outerRejected).toBeNull()`.
Addresses chatgpt-codex-connector review on PR #793
(#793 (comment)).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d66152a commit 7fb447d
2 files changed
Lines changed: 64 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1611 | 1611 | | |
1612 | 1612 | | |
1613 | 1613 | | |
1614 | | - | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
1615 | 1622 | | |
1616 | 1623 | | |
1617 | 1624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
| 1092 | + | |
| 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 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1092 | 1148 | | |
1093 | 1149 | | |
1094 | 1150 | | |
| |||
0 commit comments