diff options
Diffstat (limited to 'packages/meshbay-hub')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/index-dock.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js b/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js index 6730e60..6c89eb6 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/index-dock.js @@ -51,9 +51,18 @@ function useLoopbackActivity() { let stopped = false; let timer = null; let last = ''; + // Asked before the first operation and again after any failure: detect() + // answers "no node" as a value, where an operation on an absent node is a + // rejected IPC call that Electron prints to its terminal on every poll. + let present = false; const poll = async () => { let delay = IDLE_POLL_MS; try { + if (!present) { + const found = await platform.node.detect(); + if (!found || !found.detected) throw new Error('no node'); + present = true; + } const data = await platform.node.op('indexStatus'); const next = {}; for (const g of (data && data.groups) || []) next[g.group_id] = fromLoopback(g); @@ -64,6 +73,7 @@ function useLoopbackActivity() { if (!stopped && text !== last) { last = text; setLocal(next); } } catch { // No node on this machine, or one older than the route. + present = false; if (!stopped && last !== '{}') { last = '{}'; setLocal({}); } delay = ABSENT_POLL_MS; } |