Skip to content

Commit ae86e04

Browse files
authored
Fix debugui JS errors by switching to Map (#21)
1 parent 4feb261 commit ae86e04

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

internal/debugui/static/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ <h2>Server Capabilities</h2>
241241
const indicatorEl = document.getElementById('new-indicator');
242242

243243
let allEntries = [];
244-
let entryById = {};
244+
let entryById = new Map();
245245
let selectedId = null;
246246
let autoScroll = true;
247247

@@ -329,7 +329,7 @@ <h2>Server Capabilities</h2>
329329
if (q) {
330330
let matchText = e.method.toLowerCase() + JSON.stringify(e.body).toLowerCase();
331331
if (e.pairedWith >= 0) {
332-
const resp = entryById[e.pairedWith];
332+
const resp = entryById.get(e.pairedWith);
333333
if (resp) matchText += JSON.stringify(resp.body).toLowerCase();
334334
}
335335
if (!matchText.includes(q)) return false;
@@ -349,7 +349,7 @@ <h2>Server Capabilities</h2>
349349
let latencyHtml = '';
350350
if (e.msgType === 'request') {
351351
if (e.pairedWith >= 0) {
352-
const resp = entryById[e.pairedWith];
352+
const resp = entryById.get(e.pairedWith);
353353
if (resp) {
354354
const ms = new Date(resp.timestamp) - new Date(e.timestamp);
355355
const hasError = resp.body && JSON.stringify(resp.body).includes('"error"');
@@ -375,7 +375,7 @@ <h2>Server Capabilities</h2>
375375
detailEl.innerHTML = '<div class="empty">Select a message to view details</div>';
376376
return;
377377
}
378-
const e = entryById[selectedId];
378+
const e = entryById.get(selectedId);
379379
if (!e) return;
380380

381381
let html = `<div class="meta">#${e.id} \u00b7 ${escapeHtml(formatTime(e.timestamp))} \u00b7 ${escapeHtml(String(e.direction || ''))} \u00b7 ${escapeHtml(String(e.msgType || ''))}${e.rpcId ? ' \u00b7 id: ' + escapeHtml(String(e.rpcId)) : ''}</div>`;
@@ -384,7 +384,7 @@ <h2>Server Capabilities</h2>
384384
html += '<h3>Request</h3>';
385385
html += '<pre>' + escapeHtml(prettyJson(e.body)) + '</pre>';
386386
if (e.pairedWith >= 0) {
387-
const resp = entryById[e.pairedWith];
387+
const resp = entryById.get(e.pairedWith);
388388
if (resp) {
389389
const ms = new Date(resp.timestamp) - new Date(e.timestamp);
390390
html += `<h3>Response <span class="latency ${latencyClass(ms)}">(${formatLatency(ms)})</span></h3>`;
@@ -447,7 +447,7 @@ <h2>Server Capabilities</h2>
447447
document.getElementById('msg-clear').addEventListener('click', () => {
448448
fetch('/api/messages', { method: 'DELETE' }).then(() => {
449449
allEntries.length = 0;
450-
entryById = {};
450+
entryById = new Map();
451451
selectedId = null;
452452
renderList();
453453
renderTimeline();
@@ -554,7 +554,7 @@ <h2>Server Capabilities</h2>
554554
const t0 = new Date(e.timestamp).getTime();
555555
let t1, barClass;
556556
if (e.pairedWith >= 0) {
557-
const resp = entryById[e.pairedWith];
557+
const resp = entryById.get(e.pairedWith);
558558
if (resp) {
559559
t1 = new Date(resp.timestamp).getTime();
560560
const ms = t1 - t0;

0 commit comments

Comments
 (0)