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

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

Open
gianpaj opened this issue Mar 28, 2019 · 1 comment
Open

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

gianpaj opened this issue Mar 28, 2019 · 1 comment
Labels

Comments

@gianpaj
Copy link

gianpaj commented Mar 28, 2019

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);
      });
@callum-oakley
Copy link
Contributor

It certainly should, and that is a very unhelpful error to boot... 😬

Thanks for reporting, we'll look in to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants