Risk Level
MEDIUM
File
sdks/typescript/pmxt/ws-client.ts
Findings
- Line 243:
this.ws!.send(JSON.stringify(message));
- Line 281:
this.ws!.send(JSON.stringify(message));
this.ws is a class field that is assigned when the WebSocket connection is established. Both assertions assume the connection is live at the point of the send call. If a message is sent during reconnection, after an explicit disconnect, or before the first connection completes, this.ws is undefined and the assertion throws.
What Happens When It's Wrong
TypeError: Cannot read properties of undefined (reading 'send') — the outbound message is silently dropped and the SDK produces an unhandled exception rather than a connection error.
Suggested Fix
Guard the send, or queue the message for when the connection is re-established:
if (!this.ws) {
throw new Error('[ws-client] Cannot send: WebSocket not connected');
}
this.ws.send(JSON.stringify(message));
Found by automated non-null assertion audit
Risk Level
MEDIUM
File
sdks/typescript/pmxt/ws-client.tsFindings
this.ws!.send(JSON.stringify(message));this.ws!.send(JSON.stringify(message));this.wsis a class field that is assigned when the WebSocket connection is established. Both assertions assume the connection is live at the point of thesendcall. If a message is sent during reconnection, after an explicit disconnect, or before the first connection completes,this.wsisundefinedand the assertion throws.What Happens When It's Wrong
TypeError: Cannot read properties of undefined (reading 'send')— the outbound message is silently dropped and the SDK produces an unhandled exception rather than a connection error.Suggested Fix
Guard the send, or queue the message for when the connection is re-established:
Found by automated non-null assertion audit