Skip to content

Commit 9c279a6

Browse files
committed
Improve WebSocket message handling by skipping binary messages and refining error logging for string messages
1 parent d44d6ca commit 9c279a6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

agent-manager/src/AgentConnection.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ export class AgentConnection {
134134

135135
this.ws.onmessage = (event) => {
136136
try {
137+
// Skip binary messages (like position updates from Hyperfy)
138+
if (typeof event.data !== 'string') {
139+
return;
140+
}
141+
137142
const data = JSON.parse(event.data);
138143

139144
// Handle chat messages
@@ -150,7 +155,10 @@ export class AgentConnection {
150155

151156
// Optional: handle other message types (position updates, etc.)
152157
} catch (err) {
153-
console.error('Invalid WS message:', err);
158+
// Only log if it was a string message that failed to parse
159+
if (typeof event.data === 'string') {
160+
console.error('Invalid WS message:', err.message);
161+
}
154162
}
155163
};
156164

0 commit comments

Comments
 (0)