inf3cti0n95 / Rocket.Chat.RealTime.API.RxJS

Abstraction for Utilizing Rocket.Chat's Realtime API Methods with RxJS
MIT License
38 stars 23 forks source link

[Bug] `obj is undefined` error on login #30

Closed kawin-impekable closed 5 years ago

kawin-impekable commented 6 years ago

If Websocket Connection is terminated before getLoginObservable function is executed this error will be thrown

screen shot 2561-06-21 at 12 42 57 am

The 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.

kawin-impekable commented 6 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 :)

inf3cti0n95 commented 6 years ago

Can you tell way to recreate this bug?

kawin-impekable commented 6 years ago

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.

inf3cti0n95 commented 6 years ago

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.

kawin-impekable commented 6 years ago

sure, but it's late night here. I'll try to create a code to reproduce this tomorrow!

kawin-impekable commented 6 years ago

@inf3cti0n95 try this https://github.com/kawin-impekable/react-rocket-chat-sample

inf3cti0n95 commented 5 years ago

@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?

inf3cti0n95 commented 5 years ago

Closed, Issue fixed and released.