[React Native] SendbirdError: Connection is required

After multiple times app is going background/foreground receives this error (both iOS and Android)

Possible Unhandled Promise Rejection (id: 1):
SendbirdError: Connection is required.

How can we catch this error?

Also received such warnings:

Possible Unhandled Promise rejection (id:0)
SendbirdError: Connection is canceled.

Possible Unhandled Promise rejection (id:1)
SendbirdError: Connection is canceled.

This error happen here

this.websocketClient
...
.on('close', function () {
            c._ackStateMap.forEach(function (e) {
              console.warn('sendbird on close: websocket connection closed', e);
              e.reject(g.connectionClosed);
            }),
              c._ackStateMap.clear();
          });

Can we catch this error in application?

1 Like

In my current project, I used this approach to ignore Sendbird errors

/**
 * Ignore throw Sendbird error from chat js sdk
 */
const opts =
  require('react-native/Libraries/promiseRejectionTrackingOptions').default;

const originHandler = opts.onUnhandled;
opts.onUnhandled = (_, rejection = {code: undefined}) => {
  if (!Object.values(SendbirdErrorCode).includes(rejection.code)) {
    originHandler(_, rejection);
  }
};
1 Like