jsflow-sdk 1.0.0-rc.1 → 1.0.0-rc.3
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 +35 -1
- package/jsflow.js +2 -2
- package/package.json +1 -1
- package/sri.json +3 -3
- package/worker.js +22 -8
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,34 @@ All notable changes to `jsflow-sdk`. The format follows
|
|
|
6
6
|
contract; metric names passed to `onMetric` are diagnostic and may change in
|
|
7
7
|
any minor release.
|
|
8
8
|
|
|
9
|
+
## [1.0.0-rc.3] - 2026-11-18
|
|
10
|
+
|
|
11
|
+
The third release candidate for 1.0.0, under the npm tag `next` as before.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Two peers no longer fail to link for 10 seconds or more when one joins
|
|
15
|
+
through the other while the other is also trying to reach it.** A peer
|
|
16
|
+
joining (or rejoining) a room through another member's waiting offer
|
|
17
|
+
could, if that member also reached out to it at the same moment, send its
|
|
18
|
+
reply to the wrong place, give up on the member's connection after 4
|
|
19
|
+
seconds, and hold back from it for another 10. Both then waited without an
|
|
20
|
+
error until their attempts timed out. It was most likely with a relay
|
|
21
|
+
(TURN) configured, as in production, where a connection takes up to 1.5
|
|
22
|
+
seconds to prepare. Nothing changes on the wire or in the API.
|
|
23
|
+
|
|
24
|
+
## [1.0.0-rc.2] - 2026-11-18
|
|
25
|
+
|
|
26
|
+
The second release candidate for 1.0.0, under the npm tag `next` as before.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **A reliable message is never delivered twice across a page reload.** If a
|
|
30
|
+
receiver got a `sendReliable()` message, then reloaded (or restarted)
|
|
31
|
+
before its acknowledgement reached the sender (for example while the
|
|
32
|
+
sender's page was hidden), the sender's retransmission could reach the
|
|
33
|
+
receiver's new page as well. The new page now drops it, and the sender
|
|
34
|
+
gets `undelivered` for it, as for any message whose delivery it cannot
|
|
35
|
+
confirm. Nothing changes on the wire.
|
|
36
|
+
|
|
9
37
|
## [1.0.0-rc.1] - 2026-11-18
|
|
10
38
|
|
|
11
39
|
The release candidate for 1.0.0: everything listed under 1.0.0 below. Published under the npm tag `next`
|
|
@@ -55,7 +83,8 @@ The first stable API, on wire version 2.
|
|
|
55
83
|
6. **Tickets (optional, recommended).** Your backend signs a short-lived
|
|
56
84
|
ticket with the app's secret key (`mintTicket` in the docs, no call to
|
|
57
85
|
us) and the page passes it as `join({ ticket })`, a string or a
|
|
58
|
-
function the SDK calls
|
|
86
|
+
function the SDK calls at every `join()` call (not when a
|
|
87
|
+
page returns from `away`, nor at a token refresh). With `requireTickets` on
|
|
59
88
|
for the app, a join without one is refused. `room.user(peerId)` then
|
|
60
89
|
gives each peer's user id.
|
|
61
90
|
7. **CDN URLs.** The version directory now holds two files: `jsflow.js`
|
|
@@ -78,6 +107,11 @@ The first stable API, on wire version 2.
|
|
|
78
107
|
`SDK_VERSION`, `WIRE` and `MAX_RELIABLE` exports.
|
|
79
108
|
- Every broadcast and link-state message is signed (Ed25519) and checked
|
|
80
109
|
by every peer; forged ones are dropped where they arrive.
|
|
110
|
+
- `sendReliable()` delivers to the receiver's page that was there when it
|
|
111
|
+
was sent, never to a reloaded one: an unconfirmed message to a peer that
|
|
112
|
+
restarted is reported as `undelivered` (fixed in rc.2).
|
|
113
|
+
- Two peers that reach for each other while one joins through the other
|
|
114
|
+
link at once, instead of stalling 10 s or more (fixed in rc.3).
|
|
81
115
|
- Tokens and relay credentials refresh, so rooms live past 6 hours; the
|
|
82
116
|
signalling stream resumes after a drop without losing signals.
|
|
83
117
|
- HTTP/2 to the signalling service; rooms move between service instances
|
package/jsflow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// jsflow-sdk 1.0.0-rc.
|
|
1
|
+
// jsflow-sdk 1.0.0-rc.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
|
|
2
2
|
|
|
3
3
|
// core/link-main.js
|
|
4
4
|
function linkKind(stats) {
|
|
@@ -215,7 +215,7 @@ function ticketRegion(ticket) {
|
|
|
215
215
|
return void 0;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
var SDK_VERSION = "1.0.0-rc.
|
|
218
|
+
var SDK_VERSION = "1.0.0-rc.3";
|
|
219
219
|
var WIRE = 2;
|
|
220
220
|
var MAX_DATAGRAM = 1052;
|
|
221
221
|
var MAX_RELIABLE = 65536;
|
package/package.json
CHANGED
package/sri.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
3
|
-
"jsflow.js": "sha384-
|
|
4
|
-
"worker.js": "sha384-
|
|
2
|
+
"version": "1.0.0-rc.3",
|
|
3
|
+
"jsflow.js": "sha384-R+KY9ySstq/BD2iK1rSeAi2cc7e/TvACrSegqTksn0hr1a4shMCRUy3Y8ZU2rz7R",
|
|
4
|
+
"worker.js": "sha384-gHQ1l7u/ITLWPAt16wSLhVN9dZAYoh0DxJosUe9bt0Feft84eVIhrBHMT+BsZ8mS",
|
|
5
5
|
"jsflow.d.ts": "sha384-ZQeEwggqNXnSnd25+7iK7oiLLI636vR16LRNPNflzbnxx/IsTmEsct592Eiq2mEg"
|
|
6
6
|
}
|
package/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// jsflow-sdk 1.0.0-rc.
|
|
1
|
+
// jsflow-sdk 1.0.0-rc.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
|
|
2
2
|
|
|
3
3
|
// core/header.js
|
|
4
4
|
var VERSION = 2;
|
|
@@ -786,9 +786,9 @@ function meshNode(opts = {}) {
|
|
|
786
786
|
const sus = [...nbr.values()].filter((n) => n.sus).length;
|
|
787
787
|
if (deg() - sus >= o.target) return;
|
|
788
788
|
const now = env2.now();
|
|
789
|
-
const cand = reach.filter((x) => !banned.has(x) && !
|
|
789
|
+
const cand = reach.filter((x) => !banned.has(x) && !busy(x) && !((reject.get(x) ?? 0) > now) && (lsdb.get(x)?.links.size ?? 0) < o.max && natCompatible(o.nat, lsdb.get(x)?.nat));
|
|
790
790
|
if (!cand.length) {
|
|
791
|
-
const full = reach.filter((x) => !
|
|
791
|
+
const full = reach.filter((x) => !busy(x) && !((reject.get(x) ?? 0) > now) && natCompatible(o.nat, lsdb.get(x)?.nat));
|
|
792
792
|
if (!full.length || now < floorAt) return;
|
|
793
793
|
floorAt = now + o.floorMs;
|
|
794
794
|
env2.metric("budgetFloor", 1);
|
|
@@ -799,13 +799,16 @@ function meshNode(opts = {}) {
|
|
|
799
799
|
else pick = cand.reduce((a, b) => t.dist.get(a) <= t.dist.get(b) ? a : b);
|
|
800
800
|
attempt(pick);
|
|
801
801
|
}
|
|
802
|
+
function busy(x) {
|
|
803
|
+
return nbr.has(x) || pending2.has(x) || incoming.has(x);
|
|
804
|
+
}
|
|
802
805
|
function rescue(exclude, onDone, minAgeMs = 0) {
|
|
803
806
|
if (cloudBusy) return;
|
|
804
807
|
cloudBusy = true;
|
|
805
808
|
env2.bootstrap((peer) => {
|
|
806
809
|
cloudBusy = false;
|
|
807
810
|
onDone?.(peer !== null && peer !== void 0);
|
|
808
|
-
if (peer === null || peer === void 0 ||
|
|
811
|
+
if (peer === null || peer === void 0 || busy(peer)) return;
|
|
809
812
|
env2.metric("cloudLink", peer);
|
|
810
813
|
attempt(peer, true);
|
|
811
814
|
}, exclude, minAgeMs);
|
|
@@ -834,7 +837,7 @@ function meshNode(opts = {}) {
|
|
|
834
837
|
comps.sort((x, y) => y.length - x.length);
|
|
835
838
|
for (const c of comps.slice(1)) {
|
|
836
839
|
if (Math.min(...c) !== me) continue;
|
|
837
|
-
const big = comps[0].filter((x) => !
|
|
840
|
+
const big = comps[0].filter((x) => !busy(x) && natCompatible(o.nat, lsdb.get(x)?.nat));
|
|
838
841
|
if (big.length) {
|
|
839
842
|
env2.metric("repair", a);
|
|
840
843
|
attempt(big[Math.floor(env2.rand() * big.length)]);
|
|
@@ -1207,6 +1210,7 @@ function workerEnv({ id, inc, cloud, post, pool = null, shim = null, onMetric =
|
|
|
1207
1210
|
if (c.key && parked.get(c.key) === c) return unpark(c, why);
|
|
1208
1211
|
if (conns.get(peer) !== c) return;
|
|
1209
1212
|
conns.delete(peer);
|
|
1213
|
+
poolOid.delete(peer);
|
|
1210
1214
|
post({ op: "close", peer, n: c.n });
|
|
1211
1215
|
h2.onLinkDown(peer, c.up ? why : "failed");
|
|
1212
1216
|
}
|
|
@@ -1313,7 +1317,7 @@ function workerEnv({ id, inc, cloud, post, pool = null, shim = null, onMetric =
|
|
|
1313
1317
|
h2.onCloudSignal(from, 1, sigWrap(0, 0, enc.encode(r.sdp)));
|
|
1314
1318
|
setTimeout(() => {
|
|
1315
1319
|
const c = conns.get(from);
|
|
1316
|
-
if (c && !c.up) {
|
|
1320
|
+
if (c && !c.up && c.fromPool === r.oid) {
|
|
1317
1321
|
metric2("poolJoinTimeout", { from });
|
|
1318
1322
|
lost(from, c, "poolTimeout");
|
|
1319
1323
|
}
|
|
@@ -1365,9 +1369,11 @@ function workerEnv({ id, inc, cloud, post, pool = null, shim = null, onMetric =
|
|
|
1365
1369
|
const old = conns.get(peer);
|
|
1366
1370
|
if (old) {
|
|
1367
1371
|
conns.delete(peer);
|
|
1372
|
+
poolOid.delete(peer);
|
|
1368
1373
|
post({ op: "close", peer, n: old.n });
|
|
1369
1374
|
}
|
|
1370
1375
|
const c = fresh(peer, "answer");
|
|
1376
|
+
if (poolOid.has(peer)) c.fromPool = poolOid.get(peer);
|
|
1371
1377
|
post({ op: "answer", peer, n: c.n, sdp: dec.decode(blob) });
|
|
1372
1378
|
} else if (kind === 2) {
|
|
1373
1379
|
const c = conns.get(peer);
|
|
@@ -1381,6 +1387,7 @@ function workerEnv({ id, inc, cloud, post, pool = null, shim = null, onMetric =
|
|
|
1381
1387
|
const c = conns.get(peer);
|
|
1382
1388
|
if (c && !c.up) {
|
|
1383
1389
|
conns.delete(peer);
|
|
1390
|
+
poolOid.delete(peer);
|
|
1384
1391
|
post({ op: "close", peer, n: c.n });
|
|
1385
1392
|
}
|
|
1386
1393
|
},
|
|
@@ -1395,6 +1402,7 @@ function workerEnv({ id, inc, cloud, post, pool = null, shim = null, onMetric =
|
|
|
1395
1402
|
const c = conns.get(peer);
|
|
1396
1403
|
if (c) {
|
|
1397
1404
|
conns.delete(peer);
|
|
1405
|
+
poolOid.delete(peer);
|
|
1398
1406
|
post({ op: "close", peer, n: c.n });
|
|
1399
1407
|
}
|
|
1400
1408
|
},
|
|
@@ -1833,6 +1841,7 @@ function reliable({
|
|
|
1833
1841
|
if (Math.ceil(maxMessage / FRAG) > W) throw new RangeError("reliable: a maxMessage message must fit in the window");
|
|
1834
1842
|
if (!(rxIdleMs > giveUpMs && rxIdleMs > txIdleMs)) throw new RangeError("reliable: rxIdleMs must outlast giveUpMs and txIdleMs");
|
|
1835
1843
|
const peers = /* @__PURE__ */ new Map();
|
|
1844
|
+
const meshInc = /* @__PURE__ */ new Map();
|
|
1836
1845
|
const stats = { sent: 0, data: 0, retx: 0, fast: 0, timeLoss: 0, rto: 0, acks: 0, piggy: 0, dup: 0, delivered: 0, giveUps: 0, resets: 0, bad: 0 };
|
|
1837
1846
|
let sids = 0, sweep = null;
|
|
1838
1847
|
const bad = (why) => {
|
|
@@ -1846,7 +1855,7 @@ function reliable({
|
|
|
1846
1855
|
metric2("reliablePeersFull", peer);
|
|
1847
1856
|
return null;
|
|
1848
1857
|
}
|
|
1849
|
-
peers.set(peer, rec = { inc: 0, tx: null, rx: null, rtt: { srtt: null, var: 0, min: Infinity, latest: 0 }, seen: now(), noticeAt: -Infinity });
|
|
1858
|
+
peers.set(peer, rec = { inc: meshInc.get(peer) ?? 0, tx: null, rx: null, rtt: { srtt: null, var: 0, min: Infinity, latest: 0 }, seen: now(), noticeAt: -Infinity });
|
|
1850
1859
|
if (!sweep) sweep = setTimer(sweepMs, onSweep);
|
|
1851
1860
|
return rec;
|
|
1852
1861
|
}
|
|
@@ -2261,8 +2270,13 @@ function reliable({
|
|
|
2261
2270
|
// than the one we talk to: it restarted, so drop the old one's state now
|
|
2262
2271
|
// rather than when our retransmissions (paced by RTO backoff) reach it.
|
|
2263
2272
|
peerIncarnation(peer, pinc) {
|
|
2273
|
+
if (!(pinc <= (meshInc.get(peer) ?? 0))) meshInc.set(peer, pinc);
|
|
2264
2274
|
const rec = peers.get(peer);
|
|
2265
|
-
if (
|
|
2275
|
+
if (rec && !rec.inc) {
|
|
2276
|
+
rec.inc = pinc;
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
if (!rec || !(pinc > rec.inc)) return;
|
|
2266
2280
|
stats.resets++;
|
|
2267
2281
|
metric2("reliablePeerRestart", { peer, inc: pinc, was: rec.inc, how: "mesh" });
|
|
2268
2282
|
forget(peer, "reset");
|