Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: undefined is not an object (evaluating 'this._conversationsPromise.then') #120

Open
Reeywhaar opened this issue Sep 4, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Reeywhaar
Copy link

We get a lot of errors that this._conversationsPromise is undefined when trying to call getSubscribedConversations on a channel. Let's take a look at getSubscribedConversations:

async getSubscribedConversations() {
    await this._ensureReady;
    return this._conversationsPromise.then((conversations) => conversations.getConversations());
}

Let's look how _ensureReady is defined in client.js of @twilio/conversations

this._ensureReady = new Promise((resolve, reject) => {
    this._resolveEnsureReady = resolve;
    this._rejectEnsureReady = reject;
 }).catch(() => void 0); // @todo How to process unhandled rejection here?

Well, it seems that there is a bug here and await this._ensureReady will never throw because you swallowed the error. Since you swallowed the error we get to the next line return this._conversationsPromise.... But we can't be sure that _conversationsPromise was set.

You should remove that catch on _ensureReady in Client constructor. At least users or your library would get the original error.

@berkus
Copy link
Contributor

berkus commented Sep 4, 2023

When you remove the catch, what is the error you get?

@Reeywhaar
Copy link
Author

Also I think you should reset _ensureReady when disconnecting. I mean set _ensureReady to new Promise(... again

@Reeywhaar
Copy link
Author

When you remove the catch, what is the error you get?

Didn't try yet but I suspect it is some connectivity error

@berkus
Copy link
Contributor

berkus commented Sep 4, 2023

Yep, ok, I will take a look at that part, thank you for reporting this!

@mmubasher
Copy link

Waiting for this fix

@berkus berkus added the bug Something isn't working label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants