hcengineering/platform · warning
Unknown message format:
Error message
Unknown message format:
What it means
The hulypulse-client message handler warns 'Unknown message format:' when a WebSocket message parsed successfully but does not match any expected shape (e.g. not a result correlated to a pending request, nor a recognized event/ping structure). The message is dropped; any caller awaiting a response keeps waiting until its own timeout. It indicates a protocol mismatch between server and client.
Source
Thrown at packages/hulypulse-client/src/client.ts:206
const id = msg.correlation
if (id !== undefined && this.pending.has(id)) {
const pending = this.pending.get(id)
if (pending !== undefined) {
clearTimeout(pending.send_timeout)
this.pending.delete(id)
if ('error' in msg) {
if (typeof msg.error === 'string' && HulypulseClient.isConnectionLikeError(msg.error)) {
console.warn('Pulse server reported connection-like error; reconnecting')
this.reconnect()
}
pending.reject(new Error(msg.error))
} else {
pending.resolve(msg)
}
}
}
} else {
console.warn('Unknown message format:', msg)
}
} catch (e) {
console.error('Failed to parse message', e)
}
}
})
}
private resubscribe (): void {
for (const [key] of this.subscribes) {
this.send({ type: 'sub', key }).catch((error) => {
console.error(`Resubscription failed for key=${key}:`, error)
// throw new Error(`Resubscription failed for key=${key}: ${error.message ?? error}`)
})
}
}
private startPing (): void {View on GitHub (pinned to 63e28dc964)
Solutions
- Upgrade hulypulse-client (or server) so both sides speak the same message protocol.
- Log the full msg payload on this warning to identify the unexpected shape, then add a handler branch or fix the server.
- Check for duplicate/late responses resolving the same pending request twice.
- Inspect intermediaries (proxies, gateways) that may rewrite WebSocket frames.
Example fix
// before
console.warn('Unknown message format:', msg)
// after
console.warn('Unknown message format:', JSON.stringify(msg), 'clientVersion:', VERSION) // capture shape to align protocol Defensive patterns
Strategy: type-guard
Validate before calling
// Treat incoming messages defensively before switching on their shape
function isKnownMessage (msg: any): boolean {
return msg != null && typeof msg === 'object' && (
typeof msg.id === 'number' || typeof msg.type === 'string'
)
}
Type guard
function isResultMessage (msg: any): msg is { id: number, result: unknown } {
return typeof msg?.id === 'number' && 'result' in msg
}
Try / catch
try {
handle(msg)
} catch (e) {
console.warn('Unhandled message', JSON.stringify(msg)) // capture shape for protocol debugging
}
Prevention
- Keep client and server protocol versions in sync.
- Log full payload on unknown formats to extend the handler.
- Reject/sanitize messages at proxies between client and server.
When it happens
Trigger: Server sends a JSON message whose structure matches none of the branches in connect()'s onmessage handler - e.g. unknown 'type', missing required fields, or a response id whose pending promise was already resolved/removed.
Common situations: Server and client versions out of sync (server upgraded with new message types); a proxy injecting its own frames; server bug emitting malformed payloads; duplicate responses arriving after the pending entry was cleared.
Related errors
- The "ws" package is required for NodeWebSocketFactory.
- platform.status.ConnectionClosed
- platform.status.BadRequest
- Unknown method${method}
- Unknown method
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/5623ff54a2286767.
Report an issue: GitHub.