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
Note, placing listen() outside of
onAuthorized() doesn’t fix this or using a global variable to remember state.
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.
I’ve created a workaround hack in the meantime, but it seems that Twitch.ext is storing a global for
onTransactionComplete() that gets remembered when the browsers are different or on different machines.
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.