Commit a5d9388
authored
fix(ui): stale data modal incorrectly shown when user saves their own document (#15933)
# Overview
Fixes a race condition where the "Document Modified" modal incorrectly
appears after a user types and saves their own document.
## Key Changes
- Added `saveCounterRef` to track in-flight saves, incremented in the
Form's `onSubmit` callback
- Added a failing e2e test that reliably reproduces the race condition
## Design Decisions
The stale data check compares `originalUpdatedAt` (sent with the
form-state request) against the current DB `updatedAt`. If a save
happened while a form-state request was in-flight, the DB timestamp
advances and `isStale` returns true — correctly for *another user's*
save, but incorrectly for *your own*.
The fix captures the save counter at the start of each form-state
request and skips the stale modal if a save was initiated during that
window. The counter is incremented in `onSubmit`, which fires
synchronously before the PATCH is sent. This guarantees the counter is
already incremented before any form-state response could see our own
save's `updatedAt` as stale — closing the race window entirely.
The two-user scenario is unaffected: the counter is per-instance, so
another user's save doesn't increment the local counter and the modal
still appears correctly.1 parent 03b20d0 commit a5d9388
File tree
2 files changed
+57
-3
lines changed- packages/ui/src/views/Edit
- test/locked-documents
2 files changed
+57
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| |||
466 | 467 | | |
467 | 468 | | |
468 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
469 | 474 | | |
470 | 475 | | |
471 | 476 | | |
| |||
525 | 530 | | |
526 | 531 | | |
527 | 532 | | |
528 | | - | |
529 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
530 | 537 | | |
531 | 538 | | |
532 | 539 | | |
| |||
618 | 625 | | |
619 | 626 | | |
620 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
621 | 631 | | |
622 | 632 | | |
623 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
1790 | 1790 | | |
1791 | 1791 | | |
1792 | 1792 | | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
1793 | 1837 | | |
1794 | 1838 | | |
1795 | 1839 | | |
| |||
0 commit comments