cross-tab-worker-databus 0.20.88 → 0.20.89
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 +13 -0
- package/dist/centrifuge-session.d.ts +1 -0
- package/dist/centrifuge-session.d.ts.map +1 -1
- package/dist/centrifuge.d.ts.map +1 -1
- package/dist/centrifuge.js +55 -8
- package/dist/centrifuge.js.map +2 -2
- package/dist/centrifuge.shared.worker.js +38 -6
- package/dist/centrifuge.shared.worker.js.map +2 -2
- package/dist/centrifuge.worker.js +38 -6
- package/dist/centrifuge.worker.js.map +2 -2
- package/dist/{chunk-4UOLOWOD.js → chunk-77BQELW4.js} +20 -13
- package/dist/{chunk-4UOLOWOD.js.map → chunk-77BQELW4.js.map} +2 -2
- package/dist/cjs/centrifuge.cjs +73 -19
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +27 -14
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/core/replay-manager.d.ts.map +1 -1
- package/dist/core/trace.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +2 -2
- package/dist/websocket.d.ts.map +1 -1
- package/docs/api.md +2 -2
- package/docs/architecture.md +4 -3
- package/docs/capabilities.md +1 -1
- package/docs/configuration.md +1 -1
- package/docs/roadmap.md +12 -1
- package/docs/zh/api.md +2 -2
- package/docs/zh/architecture.md +4 -3
- package/docs/zh/capabilities.md +1 -1
- package/docs/zh/configuration.md +1 -1
- package/docs/zh/roadmap.md +12 -1
- package/package.json +1 -1
|
@@ -1533,8 +1533,9 @@ var DataBusTraceReporter = class {
|
|
|
1533
1533
|
/** Start the periodic metrics flush interval. No-op when mode is 'events'
|
|
1534
1534
|
* (no metrics to emit), when disabled, or when already running. */
|
|
1535
1535
|
start() {
|
|
1536
|
-
if (!this.enabled
|
|
1536
|
+
if (!this.enabled) return;
|
|
1537
1537
|
this.stopped = false;
|
|
1538
|
+
if (this.intervalHandle || this.mode === TRACE_MODE.EVENTS) return;
|
|
1538
1539
|
this.intervalStartedAt = this.now();
|
|
1539
1540
|
this.intervalHandle = setInterval(() => this.flush(), this.metricsIntervalMs);
|
|
1540
1541
|
}
|
|
@@ -1547,6 +1548,7 @@ var DataBusTraceReporter = class {
|
|
|
1547
1548
|
}
|
|
1548
1549
|
stop() {
|
|
1549
1550
|
this.stopped = true;
|
|
1551
|
+
this.pendingEvents = [];
|
|
1550
1552
|
this.pause();
|
|
1551
1553
|
}
|
|
1552
1554
|
/** Synchronous sink state for diagnostics: whether delivery is async and how
|
|
@@ -1557,7 +1559,7 @@ var DataBusTraceReporter = class {
|
|
|
1557
1559
|
}
|
|
1558
1560
|
/** Record an instantaneous trace event (lifecycle, status, error, etc.). */
|
|
1559
1561
|
event(event) {
|
|
1560
|
-
if (!this.enabled || this.mode === TRACE_MODE.METRICS) return;
|
|
1562
|
+
if (!this.enabled || this.stopped || this.mode === TRACE_MODE.METRICS) return;
|
|
1561
1563
|
this.emit({ ...event, timestamp: this.now() });
|
|
1562
1564
|
}
|
|
1563
1565
|
/** Synchronous snapshot of the current metrics window without resetting it.
|
|
@@ -1640,7 +1642,7 @@ var DataBusTraceReporter = class {
|
|
|
1640
1642
|
* Extracted so the four record / flush methods share one guard expression
|
|
1641
1643
|
* instead of repeating `!this.enabled || this.mode === 'events'` at each. */
|
|
1642
1644
|
get metricsActive() {
|
|
1643
|
-
return this.enabled && this.mode !== TRACE_MODE.EVENTS;
|
|
1645
|
+
return this.enabled && !this.stopped && this.mode !== TRACE_MODE.EVENTS;
|
|
1644
1646
|
}
|
|
1645
1647
|
/** Emit the accumulated metrics snapshot if the interval is active. */
|
|
1646
1648
|
flush() {
|
|
@@ -1942,6 +1944,8 @@ var ReplayManager = class {
|
|
|
1942
1944
|
* or stopped bus does not keep hammering the store) and stop the sweep. */
|
|
1943
1945
|
suspend() {
|
|
1944
1946
|
this.retryGeneration += 1;
|
|
1947
|
+
this.pendingReplayPersistence = [];
|
|
1948
|
+
this.retentionCutoff = null;
|
|
1945
1949
|
this.stop();
|
|
1946
1950
|
}
|
|
1947
1951
|
/** Drop all in-memory buffers (used on full teardown). */
|
|
@@ -2040,19 +2044,20 @@ var ReplayManager = class {
|
|
|
2040
2044
|
this.retentionCutoff = cutoff;
|
|
2041
2045
|
}
|
|
2042
2046
|
if (this.retentionCleanup) return;
|
|
2047
|
+
const generation = this.retryGeneration;
|
|
2043
2048
|
this.retentionCleanup = (async () => {
|
|
2044
|
-
while (this.retentionCutoff !== null) {
|
|
2049
|
+
while (this.retentionCutoff !== null && generation === this.retryGeneration) {
|
|
2045
2050
|
const nextCutoff = this.retentionCutoff;
|
|
2046
2051
|
this.retentionCutoff = null;
|
|
2047
2052
|
try {
|
|
2048
2053
|
await this.persistence.clearBefore(nextCutoff);
|
|
2049
2054
|
} catch (error) {
|
|
2050
|
-
this.onPersistenceError(error);
|
|
2055
|
+
if (generation === this.retryGeneration) this.onPersistenceError(error);
|
|
2051
2056
|
}
|
|
2052
2057
|
}
|
|
2053
2058
|
})().finally(() => {
|
|
2054
2059
|
this.retentionCleanup = null;
|
|
2055
|
-
if (this.retentionCutoff !== null) {
|
|
2060
|
+
if (this.retentionCutoff !== null && generation === this.retryGeneration) {
|
|
2056
2061
|
this.scheduleRetentionCleanup(this.retentionCutoff);
|
|
2057
2062
|
}
|
|
2058
2063
|
});
|
|
@@ -2069,7 +2074,9 @@ var ReplayManager = class {
|
|
|
2069
2074
|
attempt += 1;
|
|
2070
2075
|
try {
|
|
2071
2076
|
if (generation !== this.retryGeneration) throw new PersistenceRetryCancelledError();
|
|
2072
|
-
|
|
2077
|
+
const result = await operation();
|
|
2078
|
+
if (generation !== this.retryGeneration) throw new PersistenceRetryCancelledError();
|
|
2079
|
+
return result;
|
|
2073
2080
|
} catch (error) {
|
|
2074
2081
|
if (error instanceof PersistenceRetryCancelledError || generation !== this.retryGeneration) {
|
|
2075
2082
|
throw new PersistenceRetryCancelledError();
|
|
@@ -2203,7 +2210,7 @@ var DedupManager = class {
|
|
|
2203
2210
|
};
|
|
2204
2211
|
|
|
2205
2212
|
// src/core/version.ts
|
|
2206
|
-
var SDK_VERSION = true ? "0.20.
|
|
2213
|
+
var SDK_VERSION = true ? "0.20.89" : "";
|
|
2207
2214
|
|
|
2208
2215
|
// src/core/data-bus.ts
|
|
2209
2216
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -2438,8 +2445,8 @@ var CrossTabDataBus = class {
|
|
|
2438
2445
|
this.suspended = false;
|
|
2439
2446
|
this.activeConfig = config;
|
|
2440
2447
|
this.resetFailureState();
|
|
2441
|
-
this.trace.event({ type: TRACE_EVENT_TYPE.LIFECYCLE, action: TRACE_LIFECYCLE_ACTION.START });
|
|
2442
2448
|
this.trace.start();
|
|
2449
|
+
this.trace.event({ type: TRACE_EVENT_TYPE.LIFECYCLE, action: TRACE_LIFECYCLE_ACTION.START });
|
|
2443
2450
|
this.startDedupSweep();
|
|
2444
2451
|
this.replayManager.start();
|
|
2445
2452
|
this.updateStatus(WORKER_STATUS.CONNECTING);
|
|
@@ -2799,7 +2806,7 @@ var CrossTabDataBus = class {
|
|
|
2799
2806
|
getHealthSummary() {
|
|
2800
2807
|
const transport = this.transport;
|
|
2801
2808
|
const transportDown = this.status !== WORKER_STATUS.CONNECTED;
|
|
2802
|
-
const state = !this.started ? HEALTH_STATE.STOPPED : this.suspended ? HEALTH_STATE.SUSPENDED : transportDown ? this.recoveryExhausted ? HEALTH_STATE.DEGRADED : this.status === WORKER_STATUS.CONNECTING && this.recoveryAttempt === 0 ? HEALTH_STATE.STARTING : HEALTH_STATE.RECOVERING : HEALTH_STATE.HEALTHY;
|
|
2809
|
+
const state = !this.started || this.stopping ? HEALTH_STATE.STOPPED : this.suspended ? HEALTH_STATE.SUSPENDED : transportDown ? this.recoveryExhausted ? HEALTH_STATE.DEGRADED : this.status === WORKER_STATUS.CONNECTING && this.recoveryAttempt === 0 ? HEALTH_STATE.STARTING : HEALTH_STATE.RECOVERING : HEALTH_STATE.HEALTHY;
|
|
2803
2810
|
return {
|
|
2804
2811
|
healthy: state === HEALTH_STATE.HEALTHY,
|
|
2805
2812
|
state,
|
|
@@ -2870,7 +2877,7 @@ var CrossTabDataBus = class {
|
|
|
2870
2877
|
this.canceledQueuedStartToken = this.queuedStartToken;
|
|
2871
2878
|
this.queuedStart = null;
|
|
2872
2879
|
}
|
|
2873
|
-
if (this.stopPromise) return this.stopPromise;
|
|
2880
|
+
if (this.stopPromise && this.stopping) return this.stopPromise;
|
|
2874
2881
|
if (!this.started && !this.startPromise && !this.pendingStop && !this.transportReady) {
|
|
2875
2882
|
return Promise.resolve();
|
|
2876
2883
|
}
|
|
@@ -3114,8 +3121,8 @@ var CrossTabDataBus = class {
|
|
|
3114
3121
|
* pageshow path and explicit start() must run this so an explicit resume
|
|
3115
3122
|
* cannot leave trace metrics and periodic cleanup timers permanently off. */
|
|
3116
3123
|
resumeSuspendedResources() {
|
|
3117
|
-
this.trace.event({ type: TRACE_EVENT_TYPE.LIFECYCLE, action: TRACE_LIFECYCLE_ACTION.RESUME });
|
|
3118
3124
|
this.trace.start();
|
|
3125
|
+
this.trace.event({ type: TRACE_EVENT_TYPE.LIFECYCLE, action: TRACE_LIFECYCLE_ACTION.RESUME });
|
|
3119
3126
|
this.startDedupSweep();
|
|
3120
3127
|
this.replayManager.start();
|
|
3121
3128
|
}
|
|
@@ -3335,4 +3342,4 @@ export {
|
|
|
3335
3342
|
parseDataBusPublication,
|
|
3336
3343
|
selectWorkerBackend
|
|
3337
3344
|
};
|
|
3338
|
-
//# sourceMappingURL=chunk-
|
|
3345
|
+
//# sourceMappingURL=chunk-77BQELW4.js.map
|