fix: debounce SSE connection error toast (#4687)
Push container / Push branches and PRs (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Test / Typecheck (push) Has been cancelled
Test / JavaScript Tests (push) Has been cancelled
Test / Go Tests (push) Has been cancelled
Test / Go Staticcheck (push) Has been cancelled
Test / Integration Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Amir Raminfar
2026-05-09 11:50:46 -07:00
committed by GitHub
parent 1e215db588
commit d1b3507709
+19 -10
View File
@@ -31,21 +31,26 @@ export const useContainerStore = defineStore("container", () => {
return containers.value.filter(filter);
});
let errorTimer: ReturnType<typeof setTimeout> | null = null;
function connect() {
es?.close();
ready.value = false;
es = new EventSource(withBase("/api/events/stream"));
es.addEventListener("error", (e) => {
if (es?.readyState === EventSource.CONNECTING) {
showToast(
{
id: "events-stream",
message: t("error.events-stream.message"),
title: t("error.events-stream.title"),
type: "error",
},
{ once: true },
);
if (es?.readyState === EventSource.CONNECTING && errorTimer === null) {
errorTimer = setTimeout(() => {
errorTimer = null;
showToast(
{
id: "events-stream",
message: t("error.events-stream.message"),
title: t("error.events-stream.title"),
type: "error",
},
{ once: true },
);
}, 5000);
}
});
@@ -102,6 +107,10 @@ export const useContainerStore = defineStore("container", () => {
});
es.onopen = () => {
if (errorTimer !== null) {
clearTimeout(errorTimer);
errorTimer = null;
}
removeToast("events-stream");
if (containers.value.length > 0) {
containers.value = [];