Commit c7cff7c
Fix error propagation from sync clients to collections
Errors from Electric SQL and TanStack Query weren't being propagated to collections, causing two critical issues:
1. `preload()` would hang indefinitely when sync errors occurred, blocking apps waiting for data
2. Collections would be marked as 'ready' even when they had no synced data, leading to empty results
**Changes:**
- **electric-db-collection**: Implement 10-second grace period before marking collection as errored, allowing Electric's built-in retry logic to recover from transitory network issues. Remove premature `markReady()` call that was marking collections ready with no data.
- **query-db-collection**: Set error status immediately after TanStack Query exhausts retries (no grace period needed since Query handles retries internally).
- **preload()**: Listen for `status:error` events and reject the promise, preventing indefinite hangs when sync fails.
- **Collection lifecycle**: Add `markError()` method and make `events` public. Auto-handle error recovery in `markReady()` by transitioning through loading state (error → loading → ready).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 6692aad commit c7cff7c
File tree
10 files changed
+374
-33
lines changed- .beads
- packages
- db/src
- collection
- electric-db-collection
- src
- tests
- query-db-collection
- src
- tests
10 files changed
+374
-33
lines changedBinary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
813 | | - | |
| 813 | + | |
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| |||
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
823 | | - | |
| 823 | + | |
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
| |||
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
833 | | - | |
| 833 | + | |
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
843 | | - | |
| 843 | + | |
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
173 | 187 | | |
174 | 188 | | |
175 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
224 | 240 | | |
225 | 241 | | |
226 | 242 | | |
| |||
229 | 245 | | |
230 | 246 | | |
231 | 247 | | |
| 248 | + | |
232 | 249 | | |
233 | 250 | | |
234 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
590 | 594 | | |
591 | 595 | | |
592 | 596 | | |
| |||
620 | 624 | | |
621 | 625 | | |
622 | 626 | | |
623 | | - | |
| 627 | + | |
624 | 628 | | |
625 | 629 | | |
626 | 630 | | |
| |||
655 | 659 | | |
656 | 660 | | |
657 | 661 | | |
658 | | - | |
659 | | - | |
660 | 662 | | |
661 | | - | |
662 | | - | |
663 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
664 | 676 | | |
665 | 677 | | |
666 | 678 | | |
667 | 679 | | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
674 | 684 | | |
675 | | - | |
676 | | - | |
677 | 685 | | |
678 | 686 | | |
679 | 687 | | |
| |||
767 | 775 | | |
768 | 776 | | |
769 | 777 | | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
770 | 787 | | |
771 | 788 | | |
772 | 789 | | |
| |||
0 commit comments