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

[STREAM-357] - Maintain JID across hard reconnects/stanza instances from the same client. #282

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

zservies
Copy link
Collaborator

No description provided.

.then(res => res.data.chat.jabberId);
// Use stored JID if we have one, otherwise use the provided JID or grab one.
if (!this.initialJid) {
if (this.config.jid) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is actually needed, it may be redundant because we end up assigning this.config.jid = this.initialJid later too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does feel really weird actually...

So if initialJid is falsy and config.jid = 'a' for example. Then it'll be:
initialJid = config.jid = 'a'
config.jid = initialJid = 'a'

What happens if you remove this part?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the behavior is mostly the same as it was before.

The idea was - if we don't have a saved JID, then we would try to use the one in the config, but if we don't have one there then we'd fetch one.

And if we fetched one we needed to assign it to the config/saved jid. I'm not sure there's harm in it as it is, but its definitely a bit confusing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm following the intent here and I think you're right. I don't think there are any issues as is but it is strange. I'll still approve it because I think we should still be fine but out of curiosity, would there be any benefit to this.config.jid = this.initialJid being moved into the else block here? Spitballing more than anything and definitely not saying it's a necessary change, just curious more than anything.

@@ -643,19 +646,21 @@ export class Client extends EventEmitter {
}

if (this.hardReconnectRequired) {
let jidPromise: Promise<any>;
if (this.config.jid) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous code, we would automatically resolve our promise if a JID was passed in via config. What's weird though is we also grabbed the value from the promise and assigned it to config.jid even though that value is the same if we end up resolving without needing to fetch via api.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh...

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

Successfully merging this pull request may close these issues.

2 participants