Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid crashing on empty JSON data #7

Merged
merged 2 commits into from
Sep 7, 2016
Merged

Avoid crashing on empty JSON data #7

merged 2 commits into from
Sep 7, 2016

Conversation

MikeAski
Copy link
Contributor

@MikeAski MikeAski commented Sep 7, 2016

I encounter the following error on a regular basis:

/Users/mike/.rubies/ruby-2.3.1/lib/ruby/2.3.0/json/common.rb:156:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
    from /Users/mike/.rubies/ruby-2.3.1/lib/ruby/2.3.0/json/common.rb:156:in `new'
    from /Users/mike/.rubies/ruby-2.3.1/lib/ruby/2.3.0/json/common.rb:156:in `parse'
    from /Users/mike/.gem/ruby/2.3.1/gems/action_cable_client-1.3.3/lib/action_cable_client.rb:166:in `handle_received_message'
    from /Users/mike/.gem/ruby/2.3.1/gems/action_cable_client-1.3.3/lib/action_cable_client.rb:74:in `block in received'
    from /Users/mike/.gem/ruby/2.3.1/gems/em-websocket-client-0.1.2/lib/em-websocket-client.rb:43:in `receive_data'
    from /Users/mike/.gem/ruby/2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'
    from /Users/mike/.gem/ruby/2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'

This PR fixes the issue: exit processing on empty payload.

@NullVoxPopuli
Copy link
Owner

Hey! thanks for this!

Anyway you could add a test real quick?

@NullVoxPopuli
Copy link
Owner

@MikeAski what version of rails are you using?

@MikeAski
Copy link
Contributor Author

MikeAski commented Sep 7, 2016

I am using Rails 5.0.0.1

@NullVoxPopuli
Copy link
Owner

thanks for the test!

@NullVoxPopuli
Copy link
Owner

I'll get this released right away

@NullVoxPopuli NullVoxPopuli merged commit a03533d into NullVoxPopuli:master Sep 7, 2016
@NullVoxPopuli
Copy link
Owner

thanks for your work!

@MikeAski
Copy link
Contributor Author

Thanks a lot for your reactivity! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants