exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 66 forks source link

useAsync inside dynamically imported components doesn't work as intended on first run #233

Open b3nten opened 1 year ago

b3nten commented 1 year ago

useAsync calls inside of dynamically imported components push the callback into the dataStream context after the stream has finished. This means that they don't stream to the client. This only occurs the first time the server renders a page. Subsequent requests work as intended.

Here is a github repo that demonstrates this. https://github.com/B3nten/useAsync-repro

I currently have no idea why it works okay on subsequent requests, but as it does so I think it should be possible to fix.

b3nten commented 1 year ago

Reproduction: https://github.com/B3nten/ultra/tree/async-debug

Steps: 1) Run deno task dev, chose 18 (with-react-router). 2) Note console output on full refresh of pages Home and About 3) Note difference in output on subsequent refreshes of About

  1. ./about.html and ./ABOUT2.html are the returned responses from /about, on first request and second.