@tanstack/electric-db-collection 0.5.4 → 0.5.5
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/dist/cjs/electric.cjs +16 -7
- package/dist/cjs/electric.cjs.map +1 -1
- package/dist/esm/electric.js +18 -9
- package/dist/esm/electric.js.map +1 -1
- package/package.json +3 -3
- package/src/electric.ts +24 -9
package/dist/cjs/electric.cjs
CHANGED
|
@@ -188,10 +188,11 @@ function createLoadSubsetDedupe({
|
|
|
188
188
|
const snapshotParams = sqlCompiler.compileSQL(opts, compileOptions);
|
|
189
189
|
try {
|
|
190
190
|
const { data: rows } = await stream.fetchSnapshot(snapshotParams);
|
|
191
|
-
if (
|
|
191
|
+
if (!isBufferingInitialSync()) {
|
|
192
192
|
debug(`${logPrefix}Ignoring snapshot - sync completed while fetching`);
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
+
throwIfAborted();
|
|
195
196
|
if (rows.length > 0) {
|
|
196
197
|
begin();
|
|
197
198
|
for (const row of rows) {
|
|
@@ -207,12 +208,13 @@ function createLoadSubsetDedupe({
|
|
|
207
208
|
debug(`${logPrefix}Applied snapshot with ${rows.length} rows`);
|
|
208
209
|
}
|
|
209
210
|
} catch (error) {
|
|
210
|
-
if (opts.signal?.aborted) return;
|
|
211
211
|
if (handleSnapshotError(error, `fetchSnapshot`)) {
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
+
if (opts.signal?.aborted) throw abortReason(opts.signal);
|
|
214
215
|
throw error;
|
|
215
216
|
}
|
|
217
|
+
if (opts.signal?.aborted) throw abortReason(opts.signal);
|
|
216
218
|
return;
|
|
217
219
|
}
|
|
218
220
|
if (syncMode === `progressive`) {
|
|
@@ -934,8 +936,8 @@ function createElectricSync(shapeOptions, options) {
|
|
|
934
936
|
return applied;
|
|
935
937
|
};
|
|
936
938
|
const beginSourceTransaction = () => {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
+
begin();
|
|
940
|
+
metadata?.persistence?.reserveCommitTurn();
|
|
939
941
|
};
|
|
940
942
|
const syncedKeys = /* @__PURE__ */ new Set();
|
|
941
943
|
let resumeInvalid = false;
|
|
@@ -966,7 +968,7 @@ function createElectricSync(shapeOptions, options) {
|
|
|
966
968
|
};
|
|
967
969
|
lifecycle.resumeState = resetState;
|
|
968
970
|
if (metadata) {
|
|
969
|
-
begin(
|
|
971
|
+
begin();
|
|
970
972
|
metadata.collection.set(`electric:resume`, resetState);
|
|
971
973
|
if (expectInResumeSnapshot) {
|
|
972
974
|
expectCurrentCommit?.();
|
|
@@ -1273,11 +1275,18 @@ function createElectricSync(shapeOptions, options) {
|
|
|
1273
1275
|
}
|
|
1274
1276
|
}
|
|
1275
1277
|
const readyErrorVersion = streamErrorVersion;
|
|
1276
|
-
|
|
1278
|
+
const accepted = db.whenSyncAccepted(applied);
|
|
1279
|
+
if (accepted === true) {
|
|
1277
1280
|
wrappedMarkReady(wasBufferingInitialSync, readyErrorVersion);
|
|
1278
1281
|
} else {
|
|
1279
|
-
void
|
|
1282
|
+
void accepted.then(
|
|
1280
1283
|
() => wrappedMarkReady(wasBufferingInitialSync, readyErrorVersion),
|
|
1284
|
+
() => void 0
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
if (applied !== true) {
|
|
1288
|
+
void applied.then(
|
|
1289
|
+
() => void 0,
|
|
1281
1290
|
(error) => {
|
|
1282
1291
|
if (!isActiveLifecycle() || abortController.signal.aborted) {
|
|
1283
1292
|
return;
|