@signaldb/svelte 2.0.0-beta.20 → 2.0.0-beta.21
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.
|
@@ -466,10 +466,20 @@ class Collection extends EventEmitter_1.default {
|
|
|
466
466
|
queueMicrotask(() => {
|
|
467
467
|
// unregister query if no more listeners
|
|
468
468
|
const newListeners = Math.max(0, this.queryListeners({ selector, options }) - 1);
|
|
469
|
-
//
|
|
470
|
-
//
|
|
471
|
-
// before the old one's cleanup runs
|
|
472
|
-
|
|
469
|
+
// The count decides, and only the count. Asking additionally whether *this*
|
|
470
|
+
// observer was the one that registered leaks the query permanently: a rerun that
|
|
471
|
+
// creates its replacement before the old one's cleanup runs — which the microtask
|
|
472
|
+
// above deliberately allows — hands the count to an observer for which
|
|
473
|
+
// `didRegister` is false, and when that one is disposed the count reaches zero with
|
|
474
|
+
// nobody left who is allowed to act on it. The backend keeps the query registered
|
|
475
|
+
// and maintains its result on every write for the rest of the session, while
|
|
476
|
+
// `queryListeners` reads zero, so the next observer registers it a second time and
|
|
477
|
+
// is answered with the whole result again.
|
|
478
|
+
//
|
|
479
|
+
// The race that guard was written for is already covered here: an observer that
|
|
480
|
+
// registered in the meantime has incremented the count, so `newListeners` is not
|
|
481
|
+
// zero and nothing is unregistered.
|
|
482
|
+
if (newListeners === 0) {
|
|
473
483
|
this.backend.unregisterQuery(selector, options || {});
|
|
474
484
|
this.settledQueriesSet.delete((0, queryId_1.default)(selector, options));
|
|
475
485
|
}
|
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.21",
|
|
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",
|