-
Notifications
You must be signed in to change notification settings - Fork 240
Description
In our Next.js app, I noticed that replicate.stream() sometimes/often doesn't produce any events, although the web console shows that they were successfully generated. This seems to happen when the image takes longer than 60 seconds to generate. I see that fetch() receives the response headers, but then the stream closes before the response is received.
Just guessing - does Cloudfare see this as an idle connection and terminates it after a 60 second timeout? In that case, the library wouldn't be able to solve it, but the server would need to send a "ping" every 10 seconds or so to keep the connection alive.
But maybe you have other ideas? Would it make sense to detect that no "done" event was sent and just retry fetching the URL? When I manually opened the streaming URL in the browser after the connection was closed, they immediately showed the picture.