fix(terminal): track SSE opens per attempt (#1171)
Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
c550d02dc8
commit
f524880c94
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user