diff options
Diffstat (limited to 'packages/meshbay-hub/src')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/transport.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js index f7ae256..62ca2d9 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js @@ -2310,6 +2310,42 @@ class MeshBayTransport { return; } + // A bare `ack` answers three requests: sending a chat message, and storing + // or withdrawing a keypair bundle. The bundle acks name themselves in + // `detail`; the chat one carries nothing at all, so it was left to the + // arrival-order guess below — and that guess is wrong whenever anything + // else this browser asked for is still waiting. The ack went to *that* + // request, and the chat send waited out its own 30s timeout instead. + // + // What that looked like, and what this was found from: typing a message + // froze the Chat tab. The composer is disabled while a send is in flight, + // so it stopped accepting clicks and keys; the message never appeared; + // and it was there all along on the next visit to the tab, because the + // node had stored it and answered — into somebody else's promise. One + // unanswered request is enough, and an unanswered request is ordinary + // rather than exceptional: the node refuses an unknown file_id with a + // bare `error`, which names no request either and so reaches none, and a + // Videos tab that asked about a file the index no longer has leaves a + // `media_meta_req` sitting in `_pending` for the full 30s. + if (msg.type === 'ack') { + const named = msg.detail === 'keypair_bundle_stored' ? 'keypair_bundle_store' + : msg.detail === 'keypair_bundle_deleted' ? 'keypair_bundle_delete' + : null; + // Without a `detail` it is a chat ack — but a node that names neither + // is answering whichever of the three this browser has outstanding, so + // the reply is placed rather than dropped. + const wanted = named + ? [named] + : ['chat_msg', 'keypair_bundle_store', 'keypair_bundle_delete']; + for (const want of wanted) { + for (const [, handler] of this._pending) { + if (handler._reqType === want) { handler.resolve(msg); return; } + } + } + console.warn('[MeshBay] ack (detail=', msg.detail, ') with nothing waiting'); + return; + } + // Everything above is routed by something in the message. What is left is // matched by arrival order, which is only ever a guess — and a wrong guess // here hands one request's answer to another, which then waits for a reply |