API "echos" previously closed stream

I built a bot to integrate twitch stream announcements into Slack. The bot takes a list of channel names, makes a call to kraken every 60 seconds, and parses the stream objects returned against the results of the previous call. If it finds a new stream id in the return, it makes an announcement in Slack.

I’m running into an issue during testing where a stream that has stopped broadcasting will inexplicably pop back up in the API a few minutes later, prompting an announcement. The test in this case is my own stream, pushed via OBS. Note the console output below. The first run block represents the move from two active streams to one - I have terminated my stream and the API now reflects that. 60 seconds later, in the second run block, we receive only one stream (alinity), which matches the state from the first. 60 seconds later, in the third run block, we once again have a returned object from the maradine channel with the same stream id, though I am not currently broadcasting and the web UI reflects that - an announcement is made. Finally, in the fourth and fifth run blocks, the stream disappears again.

***BEGINNING TWITCH PRESENCE ENGINE RUN() BLOCK***
Placed params in request body: maradine,mojodc,alinity
Current state has 2 active streams
Received 1 active streams from API
====
Evaluating new stream with id 20602272368 from user alinity
Versus previous stream with id 20602272368 from user alinity
Match detected - not reporting to channel.
Versus previous stream with id 20603550832 from user maradine
Swapping new state to current.

***BEGINNING TWITCH PRESENCE ENGINE RUN() BLOCK***
Placed params in request body: maradine,mojodc,alinity
Current state has 1 active streams
Received 1 active streams from API
====
Evaluating new stream with id 20602272368 from user alinity
Versus previous stream with id 20602272368 from user alinity
Match detected - not reporting to channel.
Swapping new state to current.

***BEGINNING TWITCH PRESENCE ENGINE RUN() BLOCK***
Placed params in request body: maradine,mojodc,alinity
Current state has 1 active streams
Received 2 active streams from API
====
Evaluating new stream with id 20602272368 from user alinity
Versus previous stream with id 20602272368 from user alinity
Match detected - not reporting to channel.
====
Evaluating new stream with id 20603550832 from user maradine
Versus previous stream with id 20602272368 from user alinity
maradine is now streaming "Breakfast Flak" from https://www.twitch.tv/maradine
Swapping new state to current.

***BEGINNING TWITCH PRESENCE ENGINE RUN() BLOCK***
Placed params in request body: maradine,mojodc,alinity
Current state has 2 active streams
Received 1 active streams from API
====
Evaluating new stream with id 20602272368 from user alinity
Versus previous stream with id 20602272368 from user alinity
Match detected - not reporting to channel.
Versus previous stream with id 20603550832 from user maradine
Swapping new state to current.

***BEGINNING TWITCH PRESENCE ENGINE RUN() BLOCK***
Placed params in request body: maradine,mojodc,alinity
Current state has 1 active streams
Received 1 active streams from API
====
Evaluating new stream with id 20602272368 from user alinity
Versus previous stream with id 20602272368 from user alinity
Match detected - not reporting to channel.
Swapping new state to current.

This is new code, so I’m going to dive into the requests and responses themselves and doublecheck things, but the slack and twitch API wrappers I’m using are relatively mature. I also may have just plain screwed up. In the mean time, I’d love to know if this is known behavior.

Code creating output blocks for reference:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.