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

Trying to join an unexisting channel doesnt let you join correct channels #163

Open
shaaw opened this issue Jul 29, 2016 · 5 comments
Open

Comments

@shaaw
Copy link

shaaw commented Jul 29, 2016

Tittle is self explanatory.

I try to join a random channel that i know it doesnt exist to report that error on the app, but after an failed attemp to join a chat the next ones do not work even with correct ones, i have to completely reconect to the serve to make it work again. This is the log i get catching the error like in the wiki

client.join("channel").then(function(data) {
    // data returns [channel]
}).catch(function(err) {
    //
});
[14:59] info: Connected to server.
[14:59] info: Executing command: JOIN #poasjdfopasdf
No response from Twitch.
[15:00] info: Executing command: JOIN #shaawsc2
[15:00] info: Joined #shaawsc2
No response from Twitch.

It clearly says that i joined the channel, but the code goes to the reject part of the Promise

@shaaw
Copy link
Author

shaaw commented Aug 2, 2016

i think i have where the problem is
In lib/client.js

client.prototype._sendCommand = function _sendCommand(delay, channel, command, fn) {
    // Race promise against delay..
    return new Promise((resolve, reject) => {
        _.promiseDelay(delay).then(() => { reject("No response from Twitch."); });

        // Make sure the socket is opened..
        if (!_.isNull(this.ws) && this.ws.readyState !== 2 && this.ws.readyState !== 3) {
            // Executing a command on a channel..
            if (!_.isNull(channel)) {
                this.log.info(`[${_.channel(channel)}] Executing command: ${command}`);
                this.ws.send(`PRIVMSG ${_.channel(channel)} :${command}`);
            }

            // Executing a raw command..
            else {
                this.log.info(`Executing command: ${command}`);
                this.ws.send(command);
            }
            fn(resolve, reject);
        }

        // Disconnected from server..
        else { reject("Not connected to server."); }
    });
};

The command sent is raced against a timer, the first time the timer expires so it emits the error from timing out.
The second time the command is sent too but this time its correct, but it still fires the reject part of the timer.

I dont know how to fix it but maybe it helps you out.

@shaaw
Copy link
Author

shaaw commented Aug 3, 2016

Okei, i found the problem. If you comment the line 171 of events.js inside the function once
//type = type + count;
It works fine.
The problem is that when you try to join a channel the event "_promiseJoin" gets stored. If the channel doesnt exist that listener never gets removed.

The next time someone tries to join another channel the listener gets stored as "_promiseJoin2".
But the event emited is "_promiseJoin" when the system get the response from twitch, but that already timed out. But you actually joined the channel.

@Schmoopiie
Copy link
Member

I'm investigating this, thanks!

@Schmoopiie
Copy link
Member

I found the problem, will need to figure out how to fix it, when joining a channel that doesn't exist, Twitch is not returning anything, no error/notice.

The way our custom event listeners library works, we need to fire _promiseJoin to remove it from the queue, and it is not being fired because Twitch is not returning any messages.

@shaaw
Copy link
Author

shaaw commented Aug 3, 2016

Yeah, you relay on the timeout to notice that you coudnt join the channel. I tried to remove the event if the timeout expires, but i dont fully understand they way the code works and it did some weird behavior.

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

No branches or pull requests

2 participants