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
  • Loading branch information
darrachequesne committed Nov 17, 2020
1 parent 4873a23 commit 1c8cba8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/transports/polling.js
Expand Up @@ -87,7 +87,7 @@ class Polling extends Transport {
debug("polling got data %s", data);
const 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 1c8cba8

Please sign in to comment.