You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting! In my tests, I can reliably reproduce sheet.target.length === 0 on the very first invocation of prerender (typically: index.html), UNLESS I yield CPU cycles immediately after sheet.reset() (before prerender()). I presume this gives the message pump some time to flush (async_hook -related behaviour?)
This works await new Promise((res) => setTimeout(res, 0));
...at first I tried 1s, and realised it only needed a "defer" with zero delay), so I used this instead: await new Promise((res) => process.nextTick(res));
I only do this on first render, and I throw an exception if !sheet.target.length immediately after prerender().
Fun edge cases :)
The text was updated successfully, but these errors were encountered:
The async rendering stuff can be tricky. That is one of the reasons we are thinking about refactoring this API into something like const result = await sheet.collectStyles(() => prerender(app))
Interesting! In my tests, I can reliably reproduce
sheet.target.length === 0
on the very first invocation ofprerender
(typically:index.html
), UNLESS I yield CPU cycles immediately aftersheet.reset()
(beforeprerender()
). I presume this gives the message pump some time to flush (async_hook
-related behaviour?)example-wmr/public/prerender.js
Lines 12 to 14 in def977b
This works
await new Promise((res) => setTimeout(res, 0));
...at first I tried 1s, and realised it only needed a "defer" with zero delay), so I used this instead:
await new Promise((res) => process.nextTick(res));
I only do this on first render, and I throw an exception if
!sheet.target.length
immediately afterprerender()
.Fun edge cases :)
The text was updated successfully, but these errors were encountered: