PUB/SUB communication hangs after jumping between streamers


We’ve encountered an error with PUB/SUB service on production. It seems like everything is fine when we open the browser and go to one of the streamers using our extension. Then, if we change to other streamers using the same extension the extension stops getting message from PUB/SUB (checked in chrome console). Instead it starts getting {“type”:“RESPONSE”,“error”:“ERR_TOO_MANY_TOPICS”,“nonce”:"***"} message. It seems more like a an error with twitch platform than extension, but can we do anything to fix this issue?

Can anyone confirm this issue?


I believe this may be some problem with your code structure, when there is an exit, unhook or destruction event, you should be able to remove all listeners beforehand, it is common practice to remove a listener before atach a new one.

window.Twitch.ext.unlisten(‘broadcast’, ()=> console.log(‘successfully unlistened’))

I will try that, thanks. I thought extension iframe is reloading every time user change stream, isn’t it?

I don’t know exactly what happens with stages in an iframe’s lifecycle, but this listener technique is used in web development.

I did some research and it looks like this problem affects all the extensions, including big ones like Hearthstone Deck Tracker or new Borderlands 3 extension. It seems like the twitch extension documentation should more explicitly say about the need of unlistening events.

I also believe that the twitch pub/sub connection is shared between all the extensions, so even if one extension behaves correctly, the other one may drain number of topics, which will result in both extensions not working for the viewer.

1 Like

It seems like the issue was fixed globally, and extension automatically “unlisted” on watched channel change. Can we get anyone from twitch just to confirm this was fixed on their side?

Edit: I was wrong, the issue still exists. However, it looks it appears randomly. What’s more, from the extension perspective it seems like everything is correctly unlistened, so it’s probably some other part of Twtitch ecosystem that is draining topics on PUB/SUB.