Skip to content

Commit

Permalink
fix: check the type of the initial packet
Browse files Browse the repository at this point in the history
Before this fix, the client could mark the polling transport as open
even though the handshake packet was not received properly (for
example, after a parsing error).

This could lead to writes (POST requests) without "sid" query param,
which failed with:

```
{"code":2,"message":"Bad handshake method"}
```

Related:

- #636
- socketio/socket.io-client#1390

Cherry-picked from master: 1c8cba8
  • Loading branch information
darrachequesne committed Dec 30, 2020
1 parent 0b254ce commit 8750356
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/transports/polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Polling.prototype.onData = function (data) {
debug('polling got data %s', data);
var callback = function (packet, index, total) {
// if its the first message we consider the transport open
if ('opening' === self.readyState) {
if ('opening' === self.readyState && packet.type === 'open') {
self.onOpen();
}

Expand Down

0 comments on commit 8750356

Please sign in to comment.