cometchat / chat-sdk-javascript

Voice & Video Calling and Text Chat SDK for JavaScript/Web
Other
30 stars 24 forks source link

TypeError: Cannot read property 'jid' of undefined #77

Closed evgeniy-skakun closed 4 years ago

evgeniy-skakun commented 4 years ago

Describe the problem

Sometimes I see the browser throwing the TypeError: Cannot read property 'jid' of undefined error when doing this.messagesRequest.fetchPrevious() and I can't catch this error

return this.messagesRequest.fetchPrevious().then(messages => {
        // not called
    }).catch(error => {
        // not called
   });

What was the expected behavior?

when such an error occurs, I would like to be able to catch it

Reproduction

this is a floating error and I have no steps to reproduce

Environment

 "@cometchat-pro/chat": "2.1.0"

Ionic:

   Ionic CLI                     : 6.9.3
   Ionic Framework               : @ionic/angular 4.11.5
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 7.3.6
   @angular/cli                  : 7.3.6
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 24 other plugins)

Utility:

   cordova-res (update available: 0.15.1) : 0.8.1
   native-run (update available: 1.0.0)   : 0.2.9

System:

   Android SDK Tools : 26.1.1
   NodeJS            : v10.17.0
   npm               : 6.14.5
   OS                : Linux 5.3
SlavikHnatyshyn commented 4 years ago

I'm facing the same issue

SlavikHnatyshyn commented 4 years ago

Any solutions?

mayur-bhandari commented 4 years ago

Can you please check if you are connected to our WS servers? You can use CometChat.getConnectionStatus() and fetch messages if it returns CONNECTED. Also, you can use the Connection Listener, which will give real-time updates of the WS Connection.

Documentation: https://prodocs.cometchat.com/docs/js-advanced-connection-listeners

evgeniy-skakun commented 4 years ago

@mayur-bhandari Do you mean that the main reason why I have this problem is the lack of connection and to avoid such a problem I need to wait until I have the connection status "connected"?

mayur-bhandari commented 4 years ago

Hello,

Yes, the error is due to the connection to our WS server. Can you please share screenshot of the network tab (especially the WS section).

evgeniy-skakun commented 4 years ago

so far everything is working fine, I listen to the connect event and if status = connected I execute messagesRequest.fetchPrevious(). As I mentioned it is a floating error, so if everything is ok after testing, I will close the issue.