diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-22 16:40:54 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-22 16:40:54 +0200 |
| commit | 9c136a0e37add42f5d0c8675a797969cfe690de0 (patch) | |
| tree | d5dfd3a7e2289a769dc987f086eec3f475054f85 /packages/meshbay-client/src | |
| parent | 2dbd70484e65ae57e18c323381136077cd00adad (diff) | |
| download | meshbay-9c136a0e37add42f5d0c8675a797969cfe690de0.tar.gz | |
fix: first-run wizard reliability and node startup performance
Node daemon no longer blocks startup on slow directory scans — initial
indexing runs in the background so the node reaches "running" immediately
after transports are up. Fixes the wizard failing to detect the node when
large USB/NAS roots take minutes to scan.
Also: wizard key-linking deadlock resolved (main.js links during poll),
invite form stays in DOM during reconnects (disabled instead of destroyed),
pairing code bridges to renderer, and firewall docs for LAN casting added.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-client/src')
| -rw-r--r-- | packages/meshbay-client/src/main.js | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/packages/meshbay-client/src/main.js b/packages/meshbay-client/src/main.js index bfa9b48..24c1b6a 100644 --- a/packages/meshbay-client/src/main.js +++ b/packages/meshbay-client/src/main.js @@ -751,6 +751,7 @@ function registerBridge() { { signal: AbortSignal.timeout(3000) }); if (!r.ok) return null; const status = await r.json(); + if (status.status !== 'running') return null; _nodeToken = token; _nodePort = port; return { pk_node_ed25519: status.pk_node_ed25519 || '' }; @@ -798,7 +799,7 @@ function registerBridge() { provisionNode(opts.hubUrl, opts.username); } - const deadline = Date.now() + 15000; + const deadline = Date.now() + 60000; const configFile = nodeConfigPath(); let launched = false; @@ -851,13 +852,48 @@ function registerBridge() { child.unref(); } + let keyLinked = false; while (Date.now() < deadline) { await new Promise((r) => setTimeout(r, 500)); + + // If the node's admin UI is up but hub auth is stuck, link the key now. + if (!keyLinked && opts && opts.token) { + try { + const nc = readNodeConfig(); + const dd = nc ? nc.dataDir + : path.join(os.homedir(), '.local', 'share', 'meshbay'); + const tk = readNodeToken(dd); + if (tk) { + const port = nc ? nc.uiPort : 18000; + const sr = await fetch( + `http://127.0.0.1:${port}/api/status?t=${tk}`, + { signal: AbortSignal.timeout(3000) }); + if (sr.ok) { + const st = await sr.json(); + if (st.pk_node_ed25519 && + (st.status === 'waiting_for_node_key' || + st.status === 'waiting_for_account')) { + const lr = await fetch( + `${opts.hubUrl}/v1/users/me/node_key`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${opts.token}` }, + body: JSON.stringify({ + pk_node_ed25519: st.pk_node_ed25519 }), + signal: AbortSignal.timeout(5000), + }); + if (lr.ok) keyLinked = true; + } + } + } + } catch { /* best effort */ } + } + const result = await probeNode(); if (result) return { started: true, ...result }; } throw new Error( - 'meshbay-node was started but did not become ready within 15 seconds'); + 'meshbay-node was started but did not become ready within 60 seconds'); }); ipcMain.handle('node:call', async (_e, method, apiPath, body) => { |