Welcome to the Linux Foundation Forum!

LFW212 CHAP 4 STREAMING WEB CONTENT is not working in my case

Hello!

I am working on streaming data with Fastify, and I have implemented the following code. However, when I execute it, all the data is collected first before being streamed to the browser. I was expecting the data to be streamed incrementally as demonstrated in Chapter 4: Serving Web Content, Part: Streaming Content with Fastify. Could you please help me understand why the data is not being streamed progressively to the browser? What might be the issue with my implementation?

Thank you for your guidance.

Comments

  • xdxmxc
    xdxmxc Posts: 157

    @borelkoumo it could be that an optimization is being applied where a trade off is made to to buffer the content - you could pipe passThrough to reply.raw - that would eliminate any Fastify layers. Then if it still doesn't write incrementally it'll have to be something the client is doing. In that case, if you make a node client that receives the response stream you'd be able to verify for sure.

  • I share this in case somebody else as well encounters the same issue. I also had problems with chapter 4 "Streaming Content with Fastify (2)". I followed exactly the given example but when navigating to http://localhost:3000/articles?type=json&amount=250 the browser will wait that all the 250 entries are available before showing the all at once. I discovered that the issues is with Chromium, while it works as expected with Firefox.

Categories

Upcoming Training