Luci+Ucode Streaming only possible with 1kb chunks

Hi everyone,

I have a question regarding a live text stream I am implementing using ucode inside LuCI.

To avoid polling every X seconds, I am keeping a request open until just before the timeout, and then restarting it (long-polling/streaming). While this works perfectly in principle, I am facing an annoying buffering issue and I'm wondering if this behavior can be configured.

The Problem: I only receive data in the LuCI request once my stream chunks from ucode reach a size of around 1,152 bytes. It seems like something along the pipeline is buffering the output, but I can't figure out where.

Interestingly, I am pretty sure this wasn't happening in version 24.10, so it feels like something changed recently. I've spent a lot of time digging through recent commits on GitHub but couldn't find the culprit.

My Current Workaround: I am using this setup to stream data from the Podman API. Most of the time, the chunks returned by Podman are well under 1 KB. My current "fix" is to pad the chunked data with dummy bytes until it hits the ~1 KB threshold, which forces the stream to flush immediately.

Naturally, this feels like a very hacky solution. Is there a way to disable or configure this buffering behavior (e.g., forcing a flush in ucode or uhttpd)? Or am I missing something in my implementation?

You can see my actual code here: