diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-28 17:54:43 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-28 17:54:43 +0200 |
| commit | 09a007937f03fad04a390323f3817f1ae7d7c2a9 (patch) | |
| tree | dad102a6fc8592d1a84685692c23502c78f8673c /packages | |
| parent | 448ade7a463d40d264bf88b85e863fae12be9494 (diff) | |
| download | meshbay-09a007937f03fad04a390323f3817f1ae7d7c2a9.tar.gz | |
fix(transport): chat_hist_resp dispatch skipped when older pending entries exist
chat_hist_resp checked only the single oldest pending entry across all
types. When switching tabs, keyed requests (media_meta_req, file_req)
from Videos/Music/Photos stayed in _pending and were older than the
chat_hist entry, so the response was dropped and the chat appeared empty
on return. Now scans for the first chat_hist entry instead. Same fix
applied to index_sync dispatch for consistency.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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; } |