Twitch PubSub/Listen Bug

I’ve noticed a bug where multiple Listen catches and PubSub throws happen when a viewer has a channel open on two different browsers or two different computers.

The following algorithm is what triggers this bug:

Bits usage calls onTransactionComplete(), which contains an AJAX call to the EBS to perform a PubSub that is caught by listen().

Note, placing listen() outside of onAuthorized() doesn’t fix this or using a global variable to remember state.

Reproduce Bug

Method 1: Two different browsers on the same computer

Open the same Twitch channel in two different browsers on the same computer. Create a console.log('listen') in the listen() and a console.log('throw') in the onTransactionComplete(). Open your Dev Tools Console, and trigger the PubSub in the first browser by a button click to show the bits dialog window. You should see everything work correctly: one listen and one throw. Now in the other browser trigger the PubSub, and you’ll see multiple listens and throws.

Method 2: Two different computers with the same or different browsers

Open the same Twitch channel on two or more different computers. The browsers can be the same or different. (Note in method one, if the browsers are the same, you won’t see the bug.) Then repeat the triggering steps in one computer’s browser and then in the other computer’s browser. You’ll see the bug when you trigger in the second browser.

Notes:

I’ve created a workaround hack in the meantime, but it seems that Twitch.ext is storing a global for listen() or onTransactionComplete() that gets remembered when the browsers are different or on different machines.

Example:

A broadcaster has their channel open on two different computers (maybe laptop and desktop…I have not tested mobile phones, which is another common streamer setup with different computers) or two different browsers on the same computer. If a viewer then uses bits, they will see or hear what ever the bits transaction triggers multiple times. Moreover if extensions-in-chat is enabled, chat will see multiple chat notifications.

Thank you for such an extensive report!

We have passed this onto our team and they will look into it :smiley: