From 45fd9546ff77f7c7bc0437416e17ec4b4d3b0fcd Mon Sep 17 00:00:00 2001 From: you Date: Mon, 23 Mar 2026 00:16:44 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20revert=20WS=20handler=20to=20sync=20?= =?UTF-8?q?=E2=80=94=20async=20resolve=20was=20blocking=20rendering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per-observer resolve in the WS handler made it async, which broke the debounce callback (unhandled promise + race conditions). Live packets now render immediately with global cache. Per-observer resolution happens on initial load and packet detail only. --- public/index.html | 2 +- public/packets.js | 26 +------------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/public/index.html b/public/index.html index 32c88f0d..2d47e50e 100644 --- a/public/index.html +++ b/public/index.html @@ -86,7 +86,7 @@ - + diff --git a/public/packets.js b/public/packets.js index d0d4f243..82464b8e 100644 --- a/public/packets.js +++ b/public/packets.js @@ -293,31 +293,7 @@ for (const p of filtered) { try { JSON.parse(p.path_json || '[]').forEach(h => { if (!(h in hopNameCache)) newHops.add(h); }); } catch {} } - (newHops.size ? resolveHops([...newHops]) : Promise.resolve()).then(async () => { - // Per-observer resolve for ambiguous hops in this batch - const batchByObs = {}; - for (const p of filtered) { - if (!p.observer_id) continue; - try { - const path = JSON.parse(p.path_json || '[]'); - const ambig = path.filter(h => hopNameCache[h]?.ambiguous && !hopNameCache[h + ':' + p.observer_id]); - if (ambig.length) { - if (!batchByObs[p.observer_id]) batchByObs[p.observer_id] = new Set(); - ambig.forEach(h => batchByObs[p.observer_id].add(h)); - } - } catch {} - } - await Promise.all(Object.entries(batchByObs).map(async ([obsId, hopsSet]) => { - try { - const result = await api(`/resolve-hops?hops=${[...hopsSet].join(',')}&observer=${obsId}`); - if (result?.resolved) { - for (const [k, v] of Object.entries(result.resolved)) { - hopNameCache[k + ':' + obsId] = v; - } - } - } catch {} - })); - + (newHops.size ? resolveHops([...newHops]) : Promise.resolve()).then(() => { if (groupByHash) { // Update existing groups or create new ones for (const p of filtered) {