jsflow-sdk 1.0.0-rc.2 → 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 CHANGED
@@ -6,6 +6,21 @@ 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
+
9
24
  ## [1.0.0-rc.2] - 2026-11-18
10
25
 
11
26
  The second release candidate for 1.0.0, under the npm tag `next` as before.
@@ -95,6 +110,8 @@ The first stable API, on wire version 2.
95
110
  - `sendReliable()` delivers to the receiver's page that was there when it
96
111
  was sent, never to a reloaded one: an unconfirmed message to a peer that
97
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).
98
115
  - Tokens and relay credentials refresh, so rooms live past 6 hours; the
99
116
  signalling stream resumes after a drop without losing signals.
100
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.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
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.2";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsflow-sdk",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.3",
4
4
  "description": "jsflow: peer-to-peer rooms for the browser (WebRTC mesh, signalling and relays as a service).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
package/sri.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.0.0-rc.2",
3
- "jsflow.js": "sha384-TWv5Y1/UHWbfvHc9hVVcidbLAzwNnLqkRvKNozohCiccy7pZjReUXYnFpH3cM5Wt",
4
- "worker.js": "sha384-FP6p48dOLeb623bV9GRoeszT6RpUwimgxAPat059QIIDg2W8i/6hVNZZc1RAFe+2",
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.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
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) && !nbr.has(x) && !pending2.has(x) && !((reject.get(x) ?? 0) > now) && (lsdb.get(x)?.links.size ?? 0) < o.max && natCompatible(o.nat, lsdb.get(x)?.nat));
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) => !nbr.has(x) && !pending2.has(x) && !((reject.get(x) ?? 0) > now) && natCompatible(o.nat, lsdb.get(x)?.nat));
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 || nbr.has(peer) || pending2.has(peer)) return;
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) => !nbr.has(x) && !pending2.has(x) && natCompatible(o.nat, lsdb.get(x)?.nat));
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
  },