头图

After the express engine from nguniversal is rendered, the rendered HTML source code is saved in 150 lines of code html. The callback is the implementation of the ssr optimization engine developed by the Spartacus team:

When the callback is executed, maxRenderTimeout is not empty, indicating that the setTimeout driven by maxRenderTime has not been executed, which indicates that the maxRenderTime timeout has not occurred, so it will not execute to line 170.

Call callback first to return the html to the requester:

Save it in the cache:

Let's test if the render has not started until the timeout time is reached, and after the fallback to the CSR, will the SSR be executed in the background.

Let the breakpoint stop here and wait for the timeout, which is 90 seconds, one and a half minutes.

After doing housework for a while, I came back, F8, and really CSR fallback:

I also saw the corresponding log: SSR rendering exceeded timeout 90000, fallbacking to CSR for /

If the maxRenderTimeout time is reached at this time, the green highlighted code in the above figure will be executed, maxRenderTimeout will be cleared, and then the callback we specified will be called.

Note that in the context of the above figure, SSR has been successfully completed, just because maxRenderTimeout has arrived, so the rendered HTML is discarded. If timeout arrives but maxRenderTimeout does not arrive, the rendered HTML will be processed further.

More Jerry's original articles, all in: "Wang Zixi":


注销
1k 声望1.6k 粉丝

invalid