Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

How to handle no connection from the Token provider? #155

@gianpaj

Description

@gianpaj

I have a React Native app running with @pusher/chatkit-client v1.2.2

When I run it locally in development and I have forgotten to start the Token provider server, I get this a Unhandled Promise Rejection error.

Shouldn't this code catch a connect() Promise rejection?

or do I need to something with the TokenProvider class constructor?

    const chatManager = new ChatManager({
      instanceLocator: config.PUSHER_INSTANCE,
      userId,
      tokenProvider: new TokenProvider({
        url: config.PUSHER_TOKEN_PROVIDER,
        headers: {
          token,
        },
      }),
      logger: {
        error: console.error,
        warn: console.log, // adding these console.logs do not catch it
        info: console.log,
        debug: console.log,
        verbose: console.log,
      },
      connectionTimeout: PUSHER_CONN_TIMEOUT,
    });
    chatManager
      .connect()
      .then(user => {
        console.log('Pusher: connected');
        resolve();
      })
      .catch(error => {
        reject(error);
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions