cry-synced-db-client 0.1.180 → 0.1.181
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 +36 -0
- package/dist/index.js +9 -28
- package/dist/src/db/Ebus2ProxyServerUpdateNotifier.d.ts +8 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 0.1.181 (2026-05-14)
|
|
4
|
+
|
|
5
|
+
### `measureEndToEndRtt` now rides `callWorker` over the WebSocket
|
|
6
|
+
|
|
7
|
+
The old HTTP echo path was a workaround for the missing WS
|
|
8
|
+
request/response correlation in ebus-proxy 1.x. Now that
|
|
9
|
+
`callWorker` (0.1.180) provides it, `measureEndToEndRtt` becomes a
|
|
10
|
+
5-line wrapper:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
async measureEndToEndRtt(timeoutMs = 5000): Promise<number> {
|
|
14
|
+
const sentAt = Date.now();
|
|
15
|
+
const t0 = performance.now();
|
|
16
|
+
const echoed = await this.callWorker<number>("echo", sentAt, { timeoutMs });
|
|
17
|
+
if (echoed !== sentAt) throw payload-mismatch error;
|
|
18
|
+
return performance.now() - t0;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Dropped HTTP-specific code: base URL derivation (`ws://`→`http://`),
|
|
23
|
+
base64 encoding (Buffer + btoa fallback), URL query-string assembly,
|
|
24
|
+
`AbortSignal.timeout` shim, `fetch` + `arrayBuffer` + `unpack` pipeline,
|
|
25
|
+
HTTP status error branch. Bundle: 356.9 KB → 356.0 KB.
|
|
26
|
+
|
|
27
|
+
**Semantic shift**: now measures the WebSocket round-trip rather than
|
|
28
|
+
the HTTP round-trip. For this codebase that's more representative —
|
|
29
|
+
real notifications arrive on the WS, not via HTTP. The old HTTP path
|
|
30
|
+
was characterizing a transport the app barely uses (sync uploads go to
|
|
31
|
+
cry-db directly, not through ebus-proxy).
|
|
32
|
+
|
|
33
|
+
Public signature is unchanged; existing callers keep working. The
|
|
34
|
+
diagnostic interpretation table in CLAUDE.md still applies — the
|
|
35
|
+
labels just refer to the WS chain instead of the HTTP chain.
|
|
36
|
+
|
|
37
|
+
Tests: 736 bun + 18 vitest, all green.
|
|
38
|
+
|
|
3
39
|
## 0.1.180 (2026-05-14)
|
|
4
40
|
|
|
5
41
|
### `SyncedDb.callWorker` — invoke ebus2 worker services over the WS
|
package/dist/index.js
CHANGED
|
@@ -9845,41 +9845,22 @@ var Ebus2ProxyServerUpdateNotifier = class {
|
|
|
9845
9845
|
}
|
|
9846
9846
|
/**
|
|
9847
9847
|
* End-to-end RTT (client → proxy → broker → echo worker → broker →
|
|
9848
|
-
* proxy → client).
|
|
9849
|
-
*
|
|
9850
|
-
*
|
|
9851
|
-
* reporting RTT.
|
|
9848
|
+
* proxy → client). Invokes the `echo` worker via `callWorker` with
|
|
9849
|
+
* `Date.now()` as the payload; the worker returns it unchanged and
|
|
9850
|
+
* we verify byte-equality before reporting RTT.
|
|
9852
9851
|
*
|
|
9853
|
-
*
|
|
9854
|
-
*
|
|
9855
|
-
* or
|
|
9852
|
+
* Rides the existing WebSocket — same transport real notifications
|
|
9853
|
+
* arrive on, so this is the more representative diagnostic of actual
|
|
9854
|
+
* app-traffic latency. Throws on payload mismatch, timeout, or any
|
|
9855
|
+
* `callWorker` failure path (WS not OPEN, proxy error, etc).
|
|
9856
9856
|
*
|
|
9857
|
-
* @param timeoutMs Max wait for
|
|
9857
|
+
* @param timeoutMs Max wait for echo reply (default: 5000)
|
|
9858
9858
|
* @returns RTT in milliseconds (full round-trip)
|
|
9859
9859
|
*/
|
|
9860
9860
|
async measureEndToEndRtt(timeoutMs = 5e3) {
|
|
9861
|
-
const httpBase = this.wsUrl.replace(/^ws:\/\//, "http://").replace(/^wss:\/\//, "https://").replace(/\/+$/, "");
|
|
9862
9861
|
const sentAt = Date.now();
|
|
9863
|
-
const packed = packr2.pack(sentAt);
|
|
9864
|
-
let payloadB64;
|
|
9865
|
-
const bufCtor = globalThis.Buffer;
|
|
9866
|
-
if (bufCtor) {
|
|
9867
|
-
payloadB64 = bufCtor.from(packed).toString("base64");
|
|
9868
|
-
} else {
|
|
9869
|
-
let bin = "";
|
|
9870
|
-
for (let i = 0; i < packed.length; i++) bin += String.fromCharCode(packed[i]);
|
|
9871
|
-
payloadB64 = btoa(bin);
|
|
9872
|
-
}
|
|
9873
|
-
const keyParam = this.ebusProxyApiKey ? `&apikey=${encodeURIComponent(this.ebusProxyApiKey)}` : "";
|
|
9874
|
-
const url = `${httpBase}/?service=echo&payload=${encodeURIComponent(payloadB64)}${keyParam}&timeout=${timeoutMs}`;
|
|
9875
9862
|
const t0 = performance.now();
|
|
9876
|
-
const
|
|
9877
|
-
const res = await fetch(url, signal ? { signal } : void 0);
|
|
9878
|
-
if (!res.ok) {
|
|
9879
|
-
throw new Error(`[Ebus2ProxyNotifier] measureEndToEndRtt: HTTP ${res.status}`);
|
|
9880
|
-
}
|
|
9881
|
-
const buf = new Uint8Array(await res.arrayBuffer());
|
|
9882
|
-
const echoed = unpackr2.unpack(buf);
|
|
9863
|
+
const echoed = await this.callWorker("echo", sentAt, { timeoutMs });
|
|
9883
9864
|
if (echoed !== sentAt) {
|
|
9884
9865
|
throw new Error(
|
|
9885
9866
|
`[Ebus2ProxyNotifier] measureEndToEndRtt: payload mismatch (sent ${sentAt}, got ${JSON.stringify(echoed)})`
|
|
@@ -104,16 +104,16 @@ export declare class Ebus2ProxyServerUpdateNotifier implements I_ServerUpdateNot
|
|
|
104
104
|
measureWsRtt(timeoutMs?: number): Promise<number>;
|
|
105
105
|
/**
|
|
106
106
|
* End-to-end RTT (client → proxy → broker → echo worker → broker →
|
|
107
|
-
* proxy → client).
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* reporting RTT.
|
|
107
|
+
* proxy → client). Invokes the `echo` worker via `callWorker` with
|
|
108
|
+
* `Date.now()` as the payload; the worker returns it unchanged and
|
|
109
|
+
* we verify byte-equality before reporting RTT.
|
|
111
110
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* or
|
|
111
|
+
* Rides the existing WebSocket — same transport real notifications
|
|
112
|
+
* arrive on, so this is the more representative diagnostic of actual
|
|
113
|
+
* app-traffic latency. Throws on payload mismatch, timeout, or any
|
|
114
|
+
* `callWorker` failure path (WS not OPEN, proxy error, etc).
|
|
115
115
|
*
|
|
116
|
-
* @param timeoutMs Max wait for
|
|
116
|
+
* @param timeoutMs Max wait for echo reply (default: 5000)
|
|
117
117
|
* @returns RTT in milliseconds (full round-trip)
|
|
118
118
|
*/
|
|
119
119
|
measureEndToEndRtt(timeoutMs?: number): Promise<number>;
|