Closed kawin-impekable closed 5 years ago
@inf3cti0n95 I've created a PR to fix this but I'm not sure if it's the best approach to go. Please take a look when you have a free time :)
Can you tell way to recreate this bug?
What I did is call connectToServer
and then call any login
method (All of them going to call getLoginObservable
anyway) then terminate the WebSocket right away. This error will occur.
I think it related to #21 , in his case he called login
before connectToServer
so there is no response back from RealTime API and cause getLoginObservable
to throw an error.
I am still not getting, can you post the code to recreate it please. I'll review it and try to comeback to so asap.
sure, but it's late night here. I'll try to create a code to reproduce this tomorrow!
@inf3cti0n95 try this https://github.com/kawin-impekable/react-rocket-chat-sample
@kawin-impekable Sorry for being inactive. I studied the issue, the code I had written was too imperative, Could you please see the last fix that I have made. Does that solve the issue you had?
Closed, Issue fixed and released.
If Websocket Connection is terminated before
getLoginObservable
function is executed this error will be thrownThe problem is in this line
https://github.com/inf3cti0n95/Rocket.Chat.RealTime.API.RxJS/blob/master/src/RealTimeAPI.ts#L176
If I understand it correctly, when Websocket is terminated and there is no response that match the
find
operator. The.map(obj => obj[0])
statement at the end of the line will throw out this error.So my proposed fix is to add the condition to check if
obj
exist to resolve this issue.