centrifugal / centrifuge-js

JavaScript client SDK to communicate with Centrifugo and Centrifuge-based server from browser, NodeJS and React Native. Supports WebSocket, HTTP-streaming over Fetch and Readable Stream API, EventSource, WebTransport.
https://centrifugal.dev
MIT License
412 stars 104 forks source link

Cannot read property 'this._transport._transport' of undefined #74

Closed dragnet closed 5 years ago

dragnet commented 5 years ago

You have a mistake in conditions:

const transportOpen = this._transport &&
      this._transport._transport &&
      this._transport._transport.readyState === this._transport._transport.OPEN;

this._transport._transport of undefined

Need change to:

const transportOpen = this._transport && this._transport.readyState === this._transport.OPEN;
FZambia commented 5 years ago

@dragnet thanks a lot!

The reason is in difference between SockJS and Websocket - I've tested changes using only SockJS transport. Will try to add more tests in future but just don't have enough time for this :(

I believe that the problem should be fixed by 4102f04a95f6d258ef71c91affc6534d4e8ef0ea, already released 2.1.1 with this change. Could you try it and check that it works properly for you now?

dragnet commented 5 years ago

yes, it works correct for now, thanks, Alexander, you reacted very quickly