next.js
272ff8f6 - [dynamicIO] prospectively render SSR phase if needed (#71506)

Commit
1 year ago
[dynamicIO] prospectively render SSR phase if needed (#71506) Currently dynamicIO is implemented without a prospective render of the SSR portion. This is fine in most cases because we don't expect there to be dynamic IO in SSR and you can't use cache APIs in this layer. However the module scope of a lazily loaded module is semantically a static scope but as implemented it woudl execute like it was dynamic. This means things like triggering dynamic on reading the current time can happen even when we would expect it not to. The solution implemented here is to look at whether the SSR render has synchronously dynamic results. If it does we perform the render a second time. We only log during the second render. this way you see the warnings once and only if they persist across render attempts. If you read something like the current time in module scope during the first render it won't log but on the second render the module is already loaded so it also won't log and it won't abort the render early.
Author
Parents
Loading