PubSub notifications seemingly missing

I’ve integrated PubSub using the recommended flow (GitHub - twitchdev/pubsub-javascript-sample). Using that flow, I’m able to get notifications for subscribers & bits. However, there seem to be intermittent “misses” where subs/bits notifications are not received.

Couple things I’ve checked:

  • The connection did not get disconnected. I have a log of all PING/PONG and all reconnect/disconnects. The PING/PONG is consistently occurring every minute and no disconnects/reconnects are observed.
  • The token is valid for the entire time. I’ve logged every packet received on “listen” (immediately after converting to JSON). No packets were observed while the sub/bit notification was missed; indicating there wasn’t any “BADAUTH” issues observed. The following code shows how I log the listen packets:
ws = new WebSocket('wss://pubsub-edge.twitch.tv');

ws.onmessage = function(event) {
        var top_level_message = JSON.parse(event.data);

        console.log('RECV: ' + JSON.stringify(top_level_message) + '\n');
        ...
}

Any recommendations for how to debug further? Is this a known issue that PubSub can miss notifications? I understand folks are advised to use EventHooks but I believe that isn’t an option for me as I prefer the information/page to remain entirely client-side.

At this point, I’m considering going with a very non-ideal approach of querying the list of subscribers / bits leaderboard every ~10 seconds. This would mean lots of unnecessary bandwidth/processing to keep a track of all previous subs/bits and check for new ones. Open to any other ideas if anyone has them!

The Websockets transport for EventSub is in open beta, which is ideal for client-side applications where the webhook transport may not have been suitable.

That’s excessive. The Twitch API uses caching on all endpoints, so it’s not advised to poll for the exact same data more frequently than once per minute. When you poll excessively fast you also increase the risk of erroneous results where you may hit an up to date cache, and then on a subsequent request hit a stale cache that has older data than you previously received.

Thanks for the info! Marking as a potential solution as I can try out the EventSub via WebSockets to see if the missing notifications are mitigated.