Fix promise leak when result overlay is displaced by new scan

When a new scan result displaces a previously visible overlay, the promise
of the displaced overlay was never resolved. This caused the caller waiting
on that promise to block indefinitely, freezing the app.

Now the resolve function is stored in the WeakMap alongside the overlay
and timer. When a new overlay displaces the previous one, the displaced
overlay's promise is resolved immediately with resolve(), signifying that
it is no longer visible.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
vchuser
2026-07-28 17:08:25 +02:00
co-authored by Claude Opus 5
parent b965f2c9ea
commit d20f964399
+2 -1
View File
@@ -20,6 +20,7 @@ export function showResult(root, { stackId, spec, confidence }, dauerMs = 1200)
if (vorherige) {
clearTimeout(vorherige.timer);
vorherige.overlay.remove();
vorherige.resolve();
aktuelleRueckmeldung.delete(root);
}
@@ -40,6 +41,6 @@ export function showResult(root, { stackId, spec, confidence }, dauerMs = 1200)
aktuelleRueckmeldung.delete(root);
resolve();
}, dauerMs);
aktuelleRueckmeldung.set(root, { overlay, timer });
aktuelleRueckmeldung.set(root, { overlay, timer, resolve });
});
}