devongovett / rsc-html-stream

Inject an RSC payload into an HTML stream and read it back

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-Node.js env

dai-shi opened this issue · comments

Our use case doesn't depend on Node.js.

process.nextTick(async () => {

Can you use setTimeout instead?

I'm not sure if we need to wait for a tick, though.

I think it should work. Will have to check what next.js uses again. The delay is necessary to ensure the app shell is flushed before the script tags are added to the stream. That might be the whole page, or maybe not in the case of suspense, but it should always be a valid spot to insert the scripts.

Yeah looks like they use setTimeout when setImmediate isn't available. But I think setTimeout is probably fine in all cases. https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/scheduler.ts#L28

published in 0.0.3