Skip to content

Commit c597023

Browse files
fix: handle ill-formatted packet from server
The decoder can throw an error when trying to decode an invalid payload sent by the server, so the manager will now catch it, close the connection and then reconnect instead of crashing. Related: - socketio/socket.io#4392 - #1551
1 parent 8c659bc commit c597023

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/manager.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,11 @@ export class Manager<
424424
* @private
425425
*/
426426
private ondata(data): void {
427-
this.decoder.add(data);
427+
try {
428+
this.decoder.add(data);
429+
} catch (e) {
430+
this.onclose("parse error");
431+
}
428432
}
429433

430434
/**

0 commit comments

Comments
 (0)