kesha-antonov / react-native-action-cable

Use Rails 5+ ActionCable channels with React Native for realtime magic.
https://www.npmjs.com/package/@kesha-antonov/react-native-action-cable
MIT License
58 stars 24 forks source link

Crash when data in received() is null #7

Closed rodolphefauquez closed 1 year ago

rodolphefauquez commented 4 years ago

Hello! First, thanks for this fork, it's nice!

My problem:

TypeError: null is not an object (evaluating 't.action')

e#received
    subscription.js:1:1105
received
    [native code]:0
notify
    index.ios.bundle?platform=ios&dev=true&minify=false:297021:73
notify
    [native code]:0
t.prototype.events.message
    connection.js:1:3239
message
    [native code]:0
EventTarget.prototype.dispatchEvent
    event-target-shim.js:818:39
_eventEmitter.addListener$argument_1
    WebSocket.js:232:27
emit
    EventEmitter.js:190:12
callFunctionReturnFlushedQueue
    [native code]:0

It happen when the data of received() is null. Is it normal? I think it shouldn't crash, we don't necessary need any data for simple features use.

Crash is located in library's subscription.js file, in this function:

received (t) {
    return boundMethodCheck(this,e),t.action=null!=t.action?t.action:"received",this.emit(t.action,t)
  }};
kesha-antonov commented 4 years ago

Hi!

I haven't used Rails for a while. You can check that method here https://github.com/kesha-antonov/react-native-action-cable/blob/master/lib/action_cable/subscription.coffee#L29 Please make a PR if you'll make a fix and why data could be null

kesha-antonov commented 1 year ago

@rodolphefauquez just released the fix for this issue.