@signaldb/svelte 2.0.0-beta.7 → 2.0.0-beta.9
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.
|
@@ -62,13 +62,29 @@ class Collection extends EventEmitter_1.default {
|
|
|
62
62
|
const execute = () => Collection.collections.reduce((memo, collection) => () => {
|
|
63
63
|
return collection.batch(memo);
|
|
64
64
|
}, callback)();
|
|
65
|
-
const maybePromise = execute();
|
|
66
65
|
const afterBatch = () => {
|
|
67
66
|
Collection.batchOperationInProgress = false;
|
|
68
67
|
};
|
|
68
|
+
let maybePromise;
|
|
69
|
+
try {
|
|
70
|
+
maybePromise = execute();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
// A synchronously throwing callback must not leave the batch flag
|
|
74
|
+
// stuck at `true` — that would defer every requery forever (see the
|
|
75
|
+
// rejection branch below).
|
|
76
|
+
afterBatch();
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
69
79
|
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
70
80
|
return maybePromise
|
|
71
|
-
.then(() => afterBatch())
|
|
81
|
+
.then(() => afterBatch(), (error) => {
|
|
82
|
+
// Rejections need the same cleanup as fulfillment — otherwise
|
|
83
|
+
// `batchOperationInProgress` stays `true` and all deferred
|
|
84
|
+
// requeries are never flushed, silently freezing reactivity.
|
|
85
|
+
afterBatch();
|
|
86
|
+
throw error;
|
|
87
|
+
});
|
|
72
88
|
}
|
|
73
89
|
else {
|
|
74
90
|
afterBatch();
|
|
@@ -358,14 +374,31 @@ class Collection extends EventEmitter_1.default {
|
|
|
358
374
|
if (this.batchOperationInProgress)
|
|
359
375
|
return callback();
|
|
360
376
|
this.batchOperationInProgress = true;
|
|
361
|
-
const maybePromise = callback();
|
|
362
377
|
const afterBatch = () => {
|
|
363
378
|
this.batchOperationInProgress = false;
|
|
364
379
|
this.postBatchCallbacks.forEach(callback_ => callback_());
|
|
365
380
|
this.postBatchCallbacks.clear();
|
|
366
381
|
};
|
|
382
|
+
let maybePromise;
|
|
383
|
+
try {
|
|
384
|
+
maybePromise = callback();
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
// A synchronously throwing callback must not leave the batch flag
|
|
388
|
+
// stuck at `true` — that would defer every requery forever (see the
|
|
389
|
+
// rejection branch below).
|
|
390
|
+
afterBatch();
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
367
393
|
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
368
|
-
return maybePromise.then(() => afterBatch())
|
|
394
|
+
return maybePromise.then(() => afterBatch(), (error) => {
|
|
395
|
+
// Rejections need the same cleanup as fulfillment — otherwise
|
|
396
|
+
// `batchOperationInProgress` stays `true`, deferred post-batch
|
|
397
|
+
// callbacks (e.g. reactive requeries) are never flushed and
|
|
398
|
+
// reactivity silently freezes for the rest of the session.
|
|
399
|
+
afterBatch();
|
|
400
|
+
throw error;
|
|
401
|
+
});
|
|
369
402
|
}
|
|
370
403
|
else {
|
|
371
404
|
afterBatch();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaldb/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.9",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -d --noEmit false",
|
|
7
7
|
"analyze-bundle": "bundle-analyzer ./dist --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --bundle-name=@signaldb/svelte",
|