@crowdedkingdoms/crowdyjs 13.8.0 → 13.9.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"binary-relay.d.ts","sourceRoot":"","sources":["../src/binary-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAMnD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,QAAQ,CACN,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,GACnE,IAAI,CAAC;IACR;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;IACtB;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;CACV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAcxE;AAED,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MA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,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,UAAU,CAAK;gBAGrB,MAAM,EAAE,iBAAiB,EACR,SAAS,EAAE,oBAAoB;IASlD,wEAAwE;IACxE,OAAO,IAAI,OAAO;IAQlB,wEAAwE;IACxE,cAAc,IAAI,gBAAgB,GAAG,IAAI;IAIzC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAO5B,UAAU,IAAI,IAAI;IAoBlB,oEAAoE;IACpE,OAAO,IAAI,IAAI;IASf,gEAAgE;IAChE,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAUlC,OAAO,CAAC,IAAI;YAkHE,kBAAkB;IAsChC;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,UAAU;CAyBnB"}
@@ -18,6 +18,15 @@ export const RELAY_SUBPROTOCOL = 'crowdy-relay-v1';
18
18
  const BEARER_PREFIX = 'bearer.';
19
19
  /** Consecutive pre-ready failures before we declare the relay unavailable. */
20
20
  const UNAVAILABLE_AFTER_FAILURES = 2;
21
+ /**
22
+ * The same, for a relay that HAD been ready and then lost its socket.
23
+ *
24
+ * Higher than the pre-ready limit on purpose. Never having connected is
25
+ * evidence about the endpoint; a working relay dropping once is evidence about
26
+ * the network, and escalating on the first blip would move clients off healthy
27
+ * instances during an ordinary reconnect.
28
+ */
29
+ const UNAVAILABLE_AFTER_RECONNECT_FAILURES = 3;
21
30
  /**
22
31
  * Would honouring `candidate` keep us on the same site as `current`?
23
32
  *
@@ -197,8 +206,29 @@ export class BinaryRelayTransport {
197
206
  }
198
207
  if (!hadReady) {
199
208
  this.preReadyFailures += 1;
200
- if (!this.everReady && this.preReadyFailures >= UNAVAILABLE_AFTER_FAILURES) {
201
- this.logger.warn?.(`Binary relay unavailable after ${this.preReadyFailures} failed handshakes (close ${event.code}); falling back`);
209
+ // Two different failures hide behind "the handshake did not complete",
210
+ // and for a long time only one of them could ever escalate:
211
+ //
212
+ // never ready at all - the relay is not available at this endpoint,
213
+ // so fall back to the GraphQL transport.
214
+ // ready before, not now - the INSTANCE went away. This is the case
215
+ // re-discovery exists for, and `!everReady`
216
+ // excluded it.
217
+ //
218
+ // The consequence was that only a client which had never worked could
219
+ // ever be moved. A client that was healthy and whose ck-api instance
220
+ // then died retried that one dead address forever, silently: onclose
221
+ // fell through to maybeRetry, onUnavailable was never called, and so
222
+ // the re-discovery path below it never ran no matter how the caller had
223
+ // configured discoveryUrl. Measured on pgc-prod on 2026-08-06 — four
224
+ // bots pinned to a stopped instance never attempted to move.
225
+ const limit = this.everReady
226
+ ? UNAVAILABLE_AFTER_RECONNECT_FAILURES
227
+ : UNAVAILABLE_AFTER_FAILURES;
228
+ if (this.preReadyFailures >= limit) {
229
+ this.logger.warn?.(this.everReady
230
+ ? `Binary relay lost and not re-established after ${this.preReadyFailures} attempts (close ${event.code}); the instance is probably gone`
231
+ : `Binary relay unavailable after ${this.preReadyFailures} failed handshakes (close ${event.code}); falling back`);
202
232
  this.desired = false;
203
233
  this.callbacks.onUnavailable();
204
234
  return;
package/dist/index.d.ts CHANGED
@@ -45,7 +45,7 @@
45
45
  * or internal tooling, never an untrusted browser.
46
46
  */
47
47
  /** The published package version. Mirrors `package.json`. */
48
- export declare const VERSION = "13.8.0";
48
+ export declare const VERSION = "13.9.0";
49
49
  export { LbCookieStore } from './lb-cookie-store.js';
50
50
  export { CrowdyClient, createCrowdyClient, type CrowdyClientConfig, } from './crowdy-client.js';
51
51
  export { BrowserLocalStorageTokenStore, SessionStore, type SessionListener, type TokenStore, } from './session.js';
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@
45
45
  * or internal tooling, never an untrusted browser.
46
46
  */
47
47
  /** The published package version. Mirrors `package.json`. */
48
- export const VERSION = '13.8.0';
48
+ export const VERSION = '13.9.0';
49
49
  export { LbCookieStore } from './lb-cookie-store.js';
50
50
  export { CrowdyClient, createCrowdyClient, } from './crowdy-client.js';
51
51
  export { BrowserLocalStorageTokenStore, SessionStore, } from './session.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdedkingdoms/crowdyjs",
3
- "version": "13.8.0",
3
+ "version": "13.9.0",
4
4
  "description": "Browser-first Crowded Kingdoms SDK with GraphQL, realtime, and local Rust authoring support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",