Replies: 2 comments 7 replies
-
Are you letting your chunk generation be governed by the "chunk written" callback, or are you just spamming calls to # Make sure previous chunk has been written before continuing
$c->write_chunk('H' => sub ($c) {
$c->write_chunk('ell' => sub ($c) { $c->finish('o!') });
}); mojo/lib/Mojolicious/Controller.pm Line 892 in 75508c2 |
Beta Was this translation helpful? Give feedback.
6 replies
-
Apart from queueing the write_chunks as a callback and not a blocking loop, another option is to write your data to a temporary file asset and serve it with reply->file which will stream it in chunks automatically. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to make write_chunk start sending data to the client right away? I'm trying to stream large amounts of data in a controller and it seems that write_chunk just adds to a body buffer and then sends all the data after the calls to finish and rendered. I end up with an out-of-memory error.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions