summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-28 17:29:32 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-28 17:29:32 +0200
commit448ade7a463d40d264bf88b85e863fae12be9494 (patch)
treed38e93e4569ad1807dc3dc6a68b17b5f4b2f0290 /packages
parent4ef6ca817e36e207f57dd810727f7225e7d26eff (diff)
downloadmeshbay-448ade7a463d40d264bf88b85e863fae12be9494.tar.gz
fix(hub): 10s connect timeout in search page, error on unreachable download
Search-page connections (indexing and pool) now time out after 10s instead of the transport's default 30s, so down nodes are skipped faster. Downloads show a user-facing error when a group is unreachable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/files-app.js11
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/search-page.js33
2 files changed, 35 insertions, 9 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js
index 75005e2..3d51e67 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js
@@ -44,9 +44,14 @@ function FilesPanel({
const downloadFile = useCallback(async (entry) => {
let transport, gek;
if (getTransport) {
- const conn = await getTransport(entry);
- transport = conn.transport;
- gek = conn.gek;
+ try {
+ const conn = await getTransport(entry);
+ transport = conn.transport;
+ gek = conn.gek;
+ } catch {
+ setError(t('search.unreachable', { n: 1 }));
+ return;
+ }
} else {
transport = transportRef.current;
gek = gekRef.current;
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
index 5ac3ab6..e61dcd8 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/search-page.js
@@ -17,6 +17,7 @@ import { transfers } from './transfers.js';
const BATCH_SIZE = 3;
const MAX_POOL_SIZE = 3;
const DEBOUNCE_MS = 200;
+const SEARCH_TIMEOUT = 10000;
const SEARCH_VIDEO_ROOT = '__search__';
const SEARCH_AUDIO_ROOT = '__search__';
const SEARCH_PHOTO_ROOTS = ['__search_photos__'];
@@ -58,9 +59,22 @@ class ConnectionPool {
const transport = new window.MeshBayTransport(this._hubBase, live);
transport.onNeedToken = async () => (await ensureFreshToken()) || token;
- await transport.connect(
- nodesData.nodes[0].node_id, live, groupId, null, null, bundleKey,
- username, userId, null);
+ let timer;
+ try {
+ await Promise.race([
+ transport.connect(
+ nodesData.nodes[0].node_id, live, groupId, null, null, bundleKey,
+ username, userId, null),
+ new Promise((_, reject) => {
+ timer = setTimeout(() => reject(new Error('Connection timeout')), SEARCH_TIMEOUT);
+ }),
+ ]);
+ clearTimeout(timer);
+ } catch (e) {
+ clearTimeout(timer);
+ try { transport.close(); } catch {}
+ throw e;
+ }
let gek = null;
if (transport.gekRaw && window.MeshBayCrypto) {
@@ -106,9 +120,16 @@ async function fetchGroupIndex(groupId, token, bundleKey, username, userId) {
transport.onNeedToken = async () => (await ensureFreshToken()) || token;
try {
- const ack = await transport.connect(
- nodesData.nodes[0].node_id, live, groupId, null, null, bundleKey,
- username, userId, null);
+ let timer;
+ const ack = await Promise.race([
+ transport.connect(
+ nodesData.nodes[0].node_id, live, groupId, null, null, bundleKey,
+ username, userId, null),
+ new Promise((_, reject) => {
+ timer = setTimeout(() => reject(new Error('Connection timeout')), SEARCH_TIMEOUT);
+ }),
+ ]);
+ clearTimeout(timer);
const indexMsg = await transport.fetchIndex();
const roots = {