Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Response streaming #89

Open
Inkdpixels opened this issue Sep 5, 2017 · 9 comments
Open

Response streaming #89

Inkdpixels opened this issue Sep 5, 2017 · 9 comments

Comments

@Inkdpixels
Copy link

As of React 16 a new method renderToStream() method was introduced. I first though of creating a feature request issue at airbnb/hypernova-react but after taking a look at the code it seems that more ground-work needs to be done at the server itself to support streams in the first place.

@goatslacker mentioned in #22 that there are plans to support streams and even async rendering, it would be interesting if this was already started by anyone or if we could support you guys on this feature.

In the latter case it would be nice if we could collect all ideas/hints here on how to implement this feature correctly.

@ljharb
Copy link
Collaborator

ljharb commented Sep 5, 2017

* will be introduced - React 16 isn't out yet.

Definitely we'd like hypernova to support response streaming, and when available, to take advantage of renderToStream!

@goatslacker
Copy link
Collaborator

React 16 is out in beta right now I believe and the stream/async rendering has already landed so feel free to take it for a spin and report back what works/doesn't work/what you'd like to work/how @Inkdpixels

@patrick-mcdougle
Copy link

patrick-mcdougle commented May 15, 2018

What's the benefit of rendering to stream when all the markup has to be buffered to send the HTTP response to the hypernova client? Am I missing something here?

@ljharb
Copy link
Collaborator

ljharb commented May 15, 2018

@patrick-mcdougle it doesn't all have to be buffered; by simply beginning to buffer it, chunks can be immediately sent down to the client, before the rest is ready.

@patrick-mcdougle
Copy link

patrick-mcdougle commented May 16, 2018

@ljharb But the client is almost always some legacy application, which needs the JS view rendered. The hypernova client isn't ever a browser, is it?!

@ljharb
Copy link
Collaborator

ljharb commented May 16, 2018

There’s sort of a client (browser), a combo client/server (whatever talks to hypernova and the web), and a server (hypernova). The webserver absolutely might support streaming - rails 4+, for example - and the browser always does - so hypernova would have to stream also to be able to support streaming through the entire process.

@patrick-mcdougle
Copy link

I guess, but the whole response from hypernova will have to be re-tooled, since the response is JSON. You can't json_decode a partial JSON object...I guess I'm not saying it's impossible, but is it worth the effort?

@ljharb
Copy link
Collaborator

ljharb commented May 16, 2018

indeed, we'd have to use json streaming, or something similar.

I'm not sure if it's worth the effort yet - but it seems likely.

@MichalCz
Copy link

Well - looking from outside - you can indeed decode a JSON Object using JSONStream - I made quite a lot implementations using that in reading - in writing my Scramjet..toJSONArray will easily deliver a JSON array (or object via another method) items in realtime while still provinding a proper JSON output for legacy and API use.

Can you elaborate a little on the code - maybe find a nice place to make a proof of concept? I could try and help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants