Skip to content

Commit 2edd0cc

Browse files
committed
fix: catch AbortError on reload/shutdown
- Wrap abortController.abort() in try-catch in stopBackground() - Add .catch() to reader.cancel() in onAbort handler - Use deliverAs: followUp for injected screenshots
1 parent 6c06f86 commit 2edd0cc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pi/glance.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ async function backgroundLoop(
110110
// updates happen when the tool or command is invoked.
111111

112112
function stopBackground() {
113-
abortController?.abort();
113+
try {
114+
abortController?.abort();
115+
} catch {
116+
// AbortError is expected during teardown
117+
}
114118
abortController = null;
115119
currentSession = null;
116120
}
@@ -149,7 +153,7 @@ async function listenForImages(
149153

150154
const onAbort = () => {
151155
clearTimeout(timeout);
152-
reader.cancel();
156+
reader.cancel().catch(() => {});
153157
};
154158
signal.addEventListener("abort", onAbort, { once: true });
155159

0 commit comments

Comments
 (0)