Skip to content

Adding rail guard to dispatch's event param#3140

Closed
Chopinsky wants to merge 1 commit intosocketio:masterfrom
Chopinsky:fix/TypeError
Closed

Adding rail guard to dispatch's event param#3140
Chopinsky wants to merge 1 commit intosocketio:masterfrom
Chopinsky:fix/TypeError

Conversation

@Chopinsky
Copy link

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behaviour

When event packet received by onevent doesn't contain a valid array as the value of the data property, the subsequent call to dispatch will cause a TypeError, because the apply call on emit would expect the 2nd parameter to be an array type.

New behaviour

Now if event packet's data property is not already an array, we will convert it to an array before passing it to the apply call, to avoid the TypeError exception on rare occurrence of the problem as raised in issue #3139.

Other information (e.g. related issues)

There seem to be quite a few other places that would use a similar array type check in socket.js, but would rather hold off on updating all these places until further reporting of the TypeError exceptions.

@grajagandev
Copy link

Would you be interested in software that automatically finds TypeErrors like this? I am building Fuzz Stati0n to do that (free for OSS) - please take a look and consider signing up for our newsletter to keep in touch.

@darrachequesne
Copy link
Member

Closed by socketio/socket.io-parser#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants