Commit d387d26
committed
fix(sync-client): bound repo.find() + load file docs concurrently
Opening a project hung for ~60s whenever a single file doc was slow to
serve. Two compounding causes in the sync client's connect():
1. findDoc()'s repo.find() had no deadline, so it waited out
automerge-repo's own ~60s unavailable-doc timeout before rejecting.
2. loadFileDocuments() loaded every file doc SERIALLY, so that 60s stall
(and any others) summed end-to-end across the whole project.
On a large project (the smoke-all extension fixtures share one ~49-file
project) or a CPU-starved sync server, one slow doc stalled the entire
project open past any caller's budget. In the hub-client this manifested
as the Editor/preview never mounting — the dominant cause of the
smoke-all E2E flakiness (traced: a file doc's repo.find hung exactly
60.2s while the test's 75s render-wait expired). It is also a real
user-facing hang on loaded machines.
Fixes:
- Bound each repo.find() attempt with AbortSignal.timeout (5s). A timed-out
attempt is treated like the existing cold-start "unavailable" race:
retried while a peer is connected, then surfaced as `unavailable` so the
file degrades gracefully via the existing markFileUnavailable path
instead of hanging the open. (A doc that loses the race re-loads when its
index entry next changes; eager retry-on-peer-arrival remains the
separate "plan D2" gap noted in syncWithFiles.)
- Load file docs CONCURRENTLY (Promise.all) so the wait is bounded by the
single slowest doc, not the sum. Per-file unavailable handling and the
rethrow of genuine (non-unavailable) errors are preserved.
Verified: quarto-sync-client suite 102 pass; smoke-all 78/78 with no
contention (and ~30% faster); under induced heavy CPU contention the
extension-fixture failures drop from ~all to ~2/15 (the rest gated by
the shared 49-file project + retries on CI).1 parent 0940c94 commit d387d26
2 files changed
Lines changed: 76 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
209 | 241 | | |
210 | 242 | | |
211 | 243 | | |
| |||
429 | 461 | | |
430 | 462 | | |
431 | 463 | | |
432 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
433 | 472 | | |
434 | 473 | | |
435 | 474 | | |
436 | 475 | | |
437 | 476 | | |
438 | | - | |
439 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
440 | 491 | | |
441 | 492 | | |
442 | 493 | | |
| |||
553 | 604 | | |
554 | 605 | | |
555 | 606 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
565 | 625 | | |
566 | 626 | | |
567 | 627 | | |
| |||
0 commit comments