Action function stream response #8695
-
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
I had a similar problem on Firebase Functions. It was buffering the stream (it was actually Firebase Hosting's CDN doing that) and only delivering after finished. Had to move to Fly to be able to stream properly. |
Beta Was this translation helpful? Give feedback.
-
I'm facing the same scenario. Have you had any luck with resolving this? |
Beta Was this translation helpful? Give feedback.
-
Here's an article on how to use event streams with Remix. https://sergiodxa.com/tutorials/use-server-sent-events-with-remix I also have an example here. The event stream example does not depend on Single Data Fetch, so it still applies. |
Beta Was this translation helpful? Give feedback.
-
@kiliman Thanks for your reply. I don't believe that is the solution to the issue raised in this thread as SSE works only for GET requests. The action function is invoked on POST requests. If anyone has any other ideas, please share! |
Beta Was this translation helpful? Give feedback.
-
Streaming text data from an action function can get tricky, Remix doesn't have built-in functionality for it. But, we can still make it work! Might be https://remix.run/docs/en/main/guides/streaming WebSockets are best for real-time, back-and-forth communication. For pushing data from server to client, SSE or Action Data Chunking could work depending on your needs. Action Data Chunking isn't true streaming, but it can feel similar. We'd break down your data into smaller portions. In your action function, process the data chunk by chunk. After each chunk is done, you'd return an object containing the processed data and a flag indicating if there's more data to come. The client-side would handle the response and keep making requests until the flag says "stop, we're done!" Let me know if you have any questions about these approaches, or if there's another way you were thinking of tackling this. |
Beta Was this translation helpful? Give feedback.
Streaming text data from an action function can get tricky, Remix doesn't have built-in functionality for it. But, we can still make it work!
Might be https://remix.run/docs/en/main/guides/streaming
WebSockets are best for real-time, back-and-forth communication. For pushing data from server to client, SSE or Action Data Chunking could work depending on your needs.
Action Data Chunking isn't true streaming, but it can feel similar. We'd break down your data into smaller portions. In your action function, process the data chunk by chunk. After each chunk is done, you'd return an object containing the processed data and a flag indicating if there's more data to come. The client-side would h…