stoewer/go-nakadi

Infinite loop possible in streamAPI.openStream

Closed this issue · 1 comments

There is a possibility in streamAPI.openStream of infinitely looping on lines 171-182 of streams.go with no way to stop it. If openStream constantly errors, for example if trying to open an invalid subscription, the function will infinitely loop through lines 171-182, since closing of the stream is not checked there. This causes the stream to bombard Nakadi with failing calls as fast as the software can loop.

It is possible to end up in this loop even after successfully reading and closing the stream, since the select on line 200 chooses at random which branch to execute, and thus err can be something else than context.Canceled even if the streamAPI was closed, causing the loop to continue back to the beginning and going into the infinite loop.

Thanks for finding reporting this.