diff --git a/frontend/src/lib/stores/translationRun.svelte.ts b/frontend/src/lib/stores/translationRun.svelte.ts index 6d403134..ff82332d 100644 --- a/frontend/src/lib/stores/translationRun.svelte.ts +++ b/frontend/src/lib/stores/translationRun.svelte.ts @@ -143,6 +143,10 @@ function _connectWebSocket(runId: string): void { const wsUrl = getTranslateRunWsUrl(runId); _ws = new WebSocket(wsUrl); + _ws.onopen = () => { + console.debug('[translate:ws] connected', { runId }); + }; + _ws.onmessage = (event: MessageEvent) => { try { const data = JSON.parse(event.data) as Record; @@ -185,13 +189,16 @@ function _connectWebSocket(runId: string): void { }; _ws.onerror = () => { + console.warn('[translate:ws] connection error — falling back to polling', { runId }); _ws = null; }; - _ws.onclose = () => { + _ws.onclose = (event: CloseEvent) => { + console.debug('[translate:ws] closed', { runId, code: event.code, reason: event.reason }); _ws = null; }; } catch (_e) { + console.warn('[translate:ws] failed to create WebSocket', { runId, error: String(_e) }); _ws = null; } }