Open tarabishy2020 opened 2 years ago
Have a similar use case.
I want to start a async file download (via the browser file download API) and be able to leave the webpage while the download is continuing in the background.
To achieve this in Node I have to send at least 1 byte to the browser in a stream and return the correct headers. The problem is that to generate the PDF I need to perform a request to get additional data, and therefore I can't send 1 byte until the request completes; And unfortunately due to factors outside my control the request can take long periods of time.
Think Suspense helps in this case because I can renderToStream
instantly returning the parts of the PDF that are static (thus returning 1 byte to the browser immediately kicking off the download, then stream the dynamic parts through as they're ready but the user can now close the tab or leave the website and the PDF download will still complete.
There seems to be two issues mentioning Suspense - #905 and #936, but with no resolution.
I am using react-pdf in node, and I was hoping that the following would work
But I am getting
I also saw #1523, but parity in terms of how react deals with suspense would resolve this without having to add an extra Primitive.