"No tasks available" on page refresh

I have the same exact issue with image.manual but the provided snippet does not solve the problem for me (unless I'm using it wrong). When the page is refreshed a few times and it says "No tasks available", the input stream to this function (which would come from the preprocess.fetch_images or loader.get_stream in case of image.manual) actually has reached to its end. This means that get_stream in the snippet, just keeps looping in the while True loop.

Now, if I change the snippet to re-create the stream when it's fully traversed as follows, it does not stop even after all of the images are traversed.

def wrap_stream(source, api, loader):
    while True:
        stream = get_stream(source, api=api, loader=loader, input_key='image')
        stream = fetch_images(stream)
        for task in stream:
            yield task

Still trying to fix this, but also would appreciate any pointers.