fix(terminal): track SSE opens per attempt (#1171)

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-08 23:34:03 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent c550d02dc8
commit f524880c94
+4 -4
View File
@@ -786,7 +786,6 @@ const connectTerminalStreamViaSse = (
let retryTimeout: ReturnType<typeof setTimeout> | null = null;
let connectionTimeoutId: ReturnType<typeof setTimeout> | null = null;
let isClosed = false;
let hasDispatchedOpen = false;
let terminalExited = false;
const clearTimeouts = () => {
@@ -850,20 +849,21 @@ const connectTerminalStreamViaSse = (
}
eventSource = new EventSource(`/api/terminal/${sessionId}/stream`);
let opened = false;
connectionTimeoutId = setTimeout(() => {
if (!hasDispatchedOpen && eventSource?.readyState !== EventSource.OPEN) {
if (!opened && eventSource?.readyState !== EventSource.OPEN) {
eventSource?.close();
handleError(new Error('Connection timeout'), false);
}
}, connectionTimeout);
eventSource.onopen = () => {
if (hasDispatchedOpen) {
if (opened) {
return;
}
hasDispatchedOpen = true;
opened = true;
retryCount = 0;
clearTimeouts();
onEvent({ type: 'connected' });