Skip to content

Commit

Permalink
fix: handle ill-formatted packet from server
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darrachequesne committed Sep 2, 2022
1 parent 8c659bc commit c597023
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/manager.ts
Expand Up @@ -424,7 +424,11 @@ export class Manager<
* @private
*/
private ondata(data): void {
this.decoder.add(data);
try {
this.decoder.add(data);
} catch (e) {
this.onclose("parse error");
}
}

/**
Expand Down

0 comments on commit c597023

Please sign in to comment.