@johnhenry/browsermesh-discovery 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/browsermesh-discovery",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "DHT, peer discovery, naming, swarm coordination, and stealth networking for BrowserMesh",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/discovery.mjs CHANGED
@@ -518,6 +518,7 @@ export class RelayStrategy extends DiscoveryStrategy {
518
518
  this.#ws = ws;
519
519
 
520
520
  await new Promise((resolve, reject) => {
521
+ const timeoutId = setTimeout(() => reject(new Error('WebSocket connection timeout')), 10000);
521
522
  ws.onopen = async () => {
522
523
  try {
523
524
  const regMsg = { type: 'register', podId: this.#podId };
@@ -527,13 +528,17 @@ export class RelayStrategy extends DiscoveryStrategy {
527
528
  regMsg.signature = signature;
528
529
  }
529
530
  ws.send(JSON.stringify(regMsg));
531
+ clearTimeout(timeoutId);
530
532
  resolve();
531
533
  } catch (err) {
534
+ clearTimeout(timeoutId);
532
535
  reject(err);
533
536
  }
534
537
  };
535
- ws.onerror = () => reject(new Error('WebSocket connection failed'));
536
- setTimeout(() => reject(new Error('WebSocket connection timeout')), 10000);
538
+ ws.onerror = () => {
539
+ clearTimeout(timeoutId);
540
+ reject(new Error('WebSocket connection failed'));
541
+ };
537
542
  });
538
543
 
539
544
  ws.onmessage = (event) => {
@@ -1,10 +1,21 @@
1
1
  /**
2
- // STATUS: INTEGRATED — wired into ClawserPod lifecycle, proven via E2E testing
3
2
  * clawser-mesh-sw-routing.js -- ServiceWorker mesh:// fetch routing.
4
3
  *
5
4
  * Intercepts mesh:// protocol requests and *.mesh.local hostnames
6
5
  * in the Service Worker fetch handler, delegating to mesh RPC.
7
6
  *
7
+ * STATUS: `parseMeshRequest()` is wired to a real transport as of
8
+ * `browsermesh-apps`' `mesh-fetch.mjs` (Phase 2 of the
9
+ * `browsermesh-fetch-websocket.md` plan), which uses it directly to power
10
+ * `createBrowserMeshFetch()` -- a directly-callable `fetch(url, init)`-shaped
11
+ * function bound to a live `mesh-rpc` service (`mesh-rpc.mjs`, Phase 1).
12
+ * `MeshFetchRouter` in THIS file remains the separate Service-Worker
13
+ * `fetch`-event-interceptor shape (`Request` in, `Response|null` out) and is
14
+ * not itself used by `mesh-fetch.mjs` (its `Request`-in shape doesn't fit a
15
+ * direct `browserMeshFetch(url, init)` call; see that file's module doc
16
+ * comment) -- it has no wired caller of its own yet, only this module's own
17
+ * `onRpc` gap being unblocked at the transport layer.
18
+ *
8
19
  * No browser-only imports at module level.
9
20
  *
10
21
  * Run tests: