diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:51:35 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:51:35 +0200 |
| commit | 7e01b7e8c2ce2ef9fce8b6c053c3b7210b64f9bf (patch) | |
| tree | 9b5d0aae04e226e1f3c7187a4866ee421544f7a4 /packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js | |
| parent | 8125df6d8149368ed8a84c9db6c5e37bfccb5a15 (diff) | |
| download | meshbay-7e01b7e8c2ce2ef9fce8b6c053c3b7210b64f9bf.tar.gz | |
fix(spa): search names the groups refused the local network
Search gives up before ICE does, so the refusal is read from the
connection then; the walk moves on to the group's other nodes, and the
page lists the refused groups with a link to each.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js b/packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js index 15d352a7..8a616c2a 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/connection-pool.js @@ -58,6 +58,12 @@ const SEARCH_MAX_MS = 30000; * opened fine from the sidebar. A refusal naming a state of this browser (a * code, a passphrase, a device) is the same from every node and stops the * walk; `not_hosted`, a timeout or a failed connection moves on. + * + * So does a node this device refuses to reach on the local network (Android + * 17, Chrome 155: transport.js localNetworkRefused): another node of the group + * may be elsewhere. Search gives up long before connect() would name it, so it + * is read from the connection when giving up, and it is what is thrown when + * no node answered: the page says what to change rather than "unreachable". */ async function connectToGroup(hubBase, groupId, token, bundleKey, username, userId) { const nodesData = await hubFetch(`/v1/groups/${groupId}/nodes`, { token }); @@ -65,6 +71,7 @@ async function connectToGroup(hubBase, groupId, token, bundleKey, username, user const live = (await ensureFreshToken()) || token; let lastErr = null; + let lanErr = null; for (const n of nodesData.nodes) { const transport = new window.MeshBayTransport(hubBase, live); transport.onNeedToken = async () => (await ensureFreshToken()) || token; @@ -96,11 +103,16 @@ async function connectToGroup(hubBase, groupId, token, bundleKey, username, user } catch (e) { stopTimers(); lastErr = e; + if (!e.reason && await transport.localNetworkRefused()) { + lastErr = new Error('This device refused to reach the local network'); + lastErr.reason = 'local_network_blocked'; + } try { transport.close(); } catch {} + if (lastErr.reason === 'local_network_blocked') { lanErr = lastErr; continue; } if (e.reason && e.reason !== 'not_hosted') throw e; } } - throw (lastErr || new Error('no node served this group')); + throw (lanErr || lastErr || new Error('no node served this group')); } // -- Connection pool ---------------------------------------------------------- |