-
Notifications
You must be signed in to change notification settings - Fork 482
When performing the first hit on server, client re-runs everything #514
Comments
There is an open issue talking about how we can achieve a Store for exchange between server and client for at least storage / xhr calls here #489 Besides that, everything else has to be rendered again, since the client has to bootstrap itself. |
@felipedrumond So, three important things to know here. First, as @MarkPieszak pointed out, there is a separate issue for transferring state from server to client. This, however, will never solve every use case and you will need to re-pull data in various scenarios (ex. if you have client-only rendered components that need certain data). Second is that even with the current setup and without the automatic state transfer, we can help you get rid of the flicker. The flicker is due to a bug in an older version of preboot. So, forgetting about the client re-running everything (that doesn't matter...what matters is the flicker), the fix is using the most recent version of preboot. This is almost completely integrated into universal core. We should be publishing a new version of universal in the next couple days which uses the latest preboot which SHOULD solve the flicker issue. If it doesn't for whatever reason, please post something here or on the preboot repo https://github.com/angular/preboot. Last thing to be aware of is that we have discussed hydrating the client on top of the server view so even less client side logic has to be run. However, as it looks right now, if we solve the flicker issue with the latest preboot and easily allow for state transfer, the fact that rendering logic runs multiple times shouldn't make any difference. If it does, we will explore hydration more but right now it is likely not worth the effort. |
Nice! I've been considering using A2 and Universal for a project I will start working on soon and was worried that the flickering-issue would put a stop to those plans, so this fix is great news for me. Looking forward to try the new version. |
Hi @jeffwhelpley, thank you for your extensive reply! We managed to solve the flicker just by configuring the preboot to use buffer and forcing our client to call prebootComplete event after a zero-seconds timeout. @Honn, if you see the flicker, try configuring your application with the code below. main.node.ts
client.ts
|
I'm back with a new simular issue :-( My app.component.html has the following html structure: ` This way, my app constructs header (which has some requests to an web api) and footer (which has static html) only once. If I open my app at localhost:3000/company, the app will lazy load my company.module and displays its content. My company.component has static html. After requesting localhost:3000/company, node server renders the entire page (header+company+footer). The browser correctly displays it (great!), but when the app is started at the client, the content of router-outlet disappears and then reappears. Header and footer stay unchanged. I was wondering... is the router resolving the route again? |
will be fixed in ng4 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
report a bug or request a feature
When I perform the first hit on the server, the server runs the app, renders the html and delivers it to the client. The problem is that the client re-runs the app, instead keeping the app state that was downloaded from the server. This way, the user experiences a flicker/blink of the page.
When the client accesses the app for the very first time, the browser should keep the state of the result returned by the server, instead of running everything again. Also, there should be provided a strategy to choose which part of the app can be re-runed at the client side (when it is the first hit on the app). For instance, an online store could run the home component at the server, and the client could do what is particular to the user (an http request to get its cart, for example).
Having a strategy to decide the behavior of the app in different scenarios would give to developers and users a powerful experience. We could decide to run always on server, always partially on server and client or always on client.
The text was updated successfully, but these errors were encountered: