cry-synced-db-client 0.1.147 → 0.1.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### `uploadDirtyItems` follow-up pass — drain in-sync writes immediately
|
|
6
|
+
|
|
7
|
+
Writes that land **during** a sync iteration had their
|
|
8
|
+
`scheduleRestUpload()` guarded out by `isSyncing()` (silent drop, no
|
|
9
|
+
re-schedule), so they sat in `_dirty_changes` until the next 60s
|
|
10
|
+
auto-sync tick. Particularly visible for high-frequency writeOnly
|
|
11
|
+
collections (e.g. `prehodi`, written on every route change) on tablets
|
|
12
|
+
with intensive navigation: dirty items piled up until the next tick.
|
|
13
|
+
|
|
14
|
+
`SyncEngine.sync()` now performs a single follow-up pass right after the
|
|
15
|
+
primary `uploadDirtyItems()` call:
|
|
16
|
+
|
|
17
|
+
1. `flushAllPendingChanges()` — forces any in-flight 500ms Dexie
|
|
18
|
+
debounces to land in `_dirty_changes` before the second snapshot.
|
|
19
|
+
2. `uploadDirtyItems(calledFrom + ":followUp")` — drains entries that
|
|
20
|
+
accumulated during the first pass's server roundtrip.
|
|
21
|
+
|
|
22
|
+
Single pass (not a loop) — bounded work; later writes after sync
|
|
23
|
+
completes will trigger their own `scheduleRestUpload()` once the
|
|
24
|
+
`isSyncing` flag clears. Sequential `await` ordering means no concurrent
|
|
25
|
+
server roundtrips and no new race conditions vs. the existing
|
|
26
|
+
snapshot-then-clear pattern in `_dirty_changes`. Stats from the
|
|
27
|
+
follow-up pass are merged into `uploadStats` so `onSyncEnd` /
|
|
28
|
+
`collectionStats.sentCount` reflect both passes.
|
|
29
|
+
|
|
30
|
+
Errors in the follow-up are caught by the same outer `try/catch` as the
|
|
31
|
+
first pass — a follow-up failure does not roll back the first pass's
|
|
32
|
+
already-cleared dirty entries; affected items are caught at the next
|
|
33
|
+
sync tick (same retry semantics as before).
|
|
34
|
+
|
|
5
35
|
### Auto-eviction co-located with sync — one round-trip total
|
|
6
36
|
|
|
7
37
|
When `evictStaleRecordsEveryHrs > 0` and the interval has elapsed, the
|
package/dist/index.js
CHANGED
|
@@ -2553,6 +2553,17 @@ var _SyncEngine = class _SyncEngine {
|
|
|
2553
2553
|
let uploadStats = { sentCount: 0 };
|
|
2554
2554
|
try {
|
|
2555
2555
|
uploadStats = await this.uploadDirtyItems(calledFrom);
|
|
2556
|
+
await this.deps.flushAllPendingChanges();
|
|
2557
|
+
const followUp = await this.uploadDirtyItems(`${calledFrom != null ? calledFrom : "sync"}:followUp`);
|
|
2558
|
+
if (followUp.sentCount > 0) {
|
|
2559
|
+
uploadStats.sentCount += followUp.sentCount;
|
|
2560
|
+
if (followUp.collectionSentCounts) {
|
|
2561
|
+
uploadStats.collectionSentCounts = uploadStats.collectionSentCounts || {};
|
|
2562
|
+
for (const [c, n] of Object.entries(followUp.collectionSentCounts)) {
|
|
2563
|
+
uploadStats.collectionSentCounts[c] = (uploadStats.collectionSentCounts[c] || 0) + n;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2556
2567
|
} catch (err) {
|
|
2557
2568
|
console.error(
|
|
2558
2569
|
"uploadDirtyItems failed (download succeeded, staying online):",
|