cross-tab-worker-databus 0.20.17 → 0.20.19
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 +14 -0
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-LZ7S62BQ.js → chunk-TC7XXOVN.js} +16 -6
- package/dist/{chunk-LZ7S62BQ.js.map → chunk-TC7XXOVN.js.map} +2 -2
- package/dist/cjs/centrifuge.cjs +15 -5
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +15 -5
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/data-bus.d.ts +7 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/docs/configuration.md +2 -0
- package/docs/roadmap.md +11 -1
- package/docs/zh/roadmap.md +11 -1
- package/package.json +1 -1
package/dist/cjs/centrifuge.cjs
CHANGED
|
@@ -1236,7 +1236,7 @@ var PersistenceRetryCancelledError = class extends Error {
|
|
|
1236
1236
|
this.name = "PersistenceRetryCancelledError";
|
|
1237
1237
|
}
|
|
1238
1238
|
};
|
|
1239
|
-
var CrossTabDataBus = class
|
|
1239
|
+
var CrossTabDataBus = class {
|
|
1240
1240
|
transport;
|
|
1241
1241
|
cluster;
|
|
1242
1242
|
// Map of topic → set of local subscribers.
|
|
@@ -1300,7 +1300,8 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1300
1300
|
// stop to settle.
|
|
1301
1301
|
pendingStop = null;
|
|
1302
1302
|
// Minimum interval in ms between automatic recovery attempts.
|
|
1303
|
-
|
|
1303
|
+
recoveryCooldownMs;
|
|
1304
|
+
recoveryMaxAttempts;
|
|
1304
1305
|
constructor(options) {
|
|
1305
1306
|
const replay = options.replay;
|
|
1306
1307
|
if (replay) {
|
|
@@ -1330,7 +1331,15 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1330
1331
|
if (!Number.isFinite(this.persistenceRetryBackoffMs) || this.persistenceRetryBackoffMs < 0) {
|
|
1331
1332
|
throw new TypeError("replay.persistenceRetry.backoffMs must be a non-negative finite number.");
|
|
1332
1333
|
}
|
|
1333
|
-
const { autoStart, initialConfig, trace, transport, dedup, ...clusterOptions } = options;
|
|
1334
|
+
const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
|
|
1335
|
+
this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
|
|
1336
|
+
this.recoveryMaxAttempts = recovery?.maxAttempts ?? Number.POSITIVE_INFINITY;
|
|
1337
|
+
if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
|
|
1338
|
+
throw new TypeError("recovery.cooldownMs must be a positive finite number.");
|
|
1339
|
+
}
|
|
1340
|
+
if (!(this.recoveryMaxAttempts === Number.POSITIVE_INFINITY || Number.isSafeInteger(this.recoveryMaxAttempts) && this.recoveryMaxAttempts > 0)) {
|
|
1341
|
+
throw new TypeError("recovery.maxAttempts must be a positive safe integer.");
|
|
1342
|
+
}
|
|
1334
1343
|
this.now = dedup?.now ?? Date.now;
|
|
1335
1344
|
this.replayHydration = this.hydrateReplay();
|
|
1336
1345
|
this.transport = transport;
|
|
@@ -1886,15 +1895,16 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1886
1895
|
}
|
|
1887
1896
|
if (status === "error" && this.started && !this.stopping) {
|
|
1888
1897
|
const now = this.now();
|
|
1889
|
-
if (now - this.lastRecoveryAt >=
|
|
1898
|
+
if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
|
|
1890
1899
|
this.lastRecoveryAt = now;
|
|
1891
1900
|
const attempt = ++this.recoveryAttempt;
|
|
1901
|
+
if (attempt > this.recoveryMaxAttempts) return;
|
|
1892
1902
|
this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
|
|
1893
1903
|
setTimeout(() => {
|
|
1894
1904
|
if (this.stopping || !this.started || this.suspended) return;
|
|
1895
1905
|
if (this.status !== "error") return;
|
|
1896
1906
|
void this.reopenTransport(attempt);
|
|
1897
|
-
},
|
|
1907
|
+
}, this.recoveryCooldownMs);
|
|
1898
1908
|
}
|
|
1899
1909
|
}
|
|
1900
1910
|
this.invokeHandlers(this.statusHandlers, (handler) => handler(status));
|