inf3cti0n95 / Rocket.Chat.RealTime.API.RxJS

Abstraction for Utilizing Rocket.Chat's Realtime API Methods with RxJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] `obj is undefined` error on login

kawin-impekable opened this issue · comments

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.

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

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