diff options
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/transport.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js index 1a146ce..120c7d7 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js @@ -2121,9 +2121,11 @@ class MeshBayTransport { if (msg.type === 'index_sync' && msg.entries) { if (this._onIndexSync) this._onIndexSync(msg); - const oldest = this._pending.entries().next(); - if (!oldest.done && oldest.value[1]._reqType === 'index_sync') { - oldest.value[1].resolve(msg); + for (const [, handler] of this._pending) { + if (handler._reqType === 'index_sync') { + handler.resolve(msg); + break; + } } return; } @@ -2251,12 +2253,13 @@ class MeshBayTransport { // what depending on response arrival order rather than on request type // predicts: it fires only when the two responses happen to reorder. if (msg.type === 'chat_hist_resp') { - const oldest = this._pending.entries().next(); - if (!oldest.done && oldest.value[1]._reqType === 'chat_hist') { - oldest.value[1].resolve(msg); - } else { - console.warn('[MeshBay] chat_hist_resp with no matching chat_hist pending'); + for (const [, handler] of this._pending) { + if (handler._reqType === 'chat_hist') { + handler.resolve(msg); + return; + } } + console.warn('[MeshBay] chat_hist_resp with no matching chat_hist pending'); return; } |