Commit ef15b7f
committed
refactor: simplify createWriteCheckpoint Cosmos DB HEAD capture
Replace the polling loop in createWriteCheckpoint with a direct read
of the current storage checkpoint LSN.
The polling loop (get baseline → write sentinel → poll until LSN
advances) was unnecessary: with >= comparison, the poll always resolved
on the first iteration because the baseline LSN was already in storage.
The loop was effectively just reading the current LSN.
The simplified version reads the current checkpoint LSN directly and
uses it as HEAD. This is correct because:
- createReplicationHead already wrote a sentinel to _powersync_checkpoints
- The sentinel guarantees the streaming loop will advance past this point
- The HEAD just needs to be a valid LSN at or before the sentinel
- The sync stream resolves the write checkpoint when replication advances
Removes ~15 lines of polling/timeout code.1 parent 04063d1 commit ef15b7f
1 file changed
Lines changed: 17 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
45 | 39 | | |
| 40 | + | |
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
| |||
0 commit comments