Add WebSocket error handling with stack traces

Wrapped ws.onmessage in try-catch to capture full stack trace
when errors occur during message handling. This will help identify
where the 'Cannot read properties of undefined' error is coming from.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-07 23:33:07 -05:00
parent 025aa11f34
commit 8721e47a4a

View File

@@ -2458,8 +2458,9 @@
ws = new WebSocket(`${protocol}//${window.location.host}`); ws = new WebSocket(`${protocol}//${window.location.host}`);
ws.onmessage = (event) => { ws.onmessage = (event) => {
const data = JSON.parse(event.data); try {
console.log('WebSocket message:', data); const data = JSON.parse(event.data);
console.log('WebSocket message:', data);
// Handle specific message types // Handle specific message types
if (data.type === 'command_result') { if (data.type === 'command_result') {
@@ -2521,9 +2522,13 @@
loadWorkflows(); loadWorkflows();
} }
// Generic refresh for other message types // Generic refresh for other message types
if (!['command_result', 'workflow_result', 'worker_update', 'execution_started', 'execution_status', 'workflow_created', 'workflow_deleted'].includes(data.type)) { if (!['command_result', 'workflow_result', 'worker_update', 'execution_started', 'execution_status', 'workflow_created', 'workflow_deleted'].includes(data.type)) {
refreshData(); refreshData();
}
} catch (error) {
console.error('Error handling WebSocket message:', error);
console.error('Stack trace:', error.stack);
} }
}; };