-
Notifications
You must be signed in to change notification settings - Fork 50
server app instance not removed from DOM after client bootstraps app #111
Comments
@mohamedaarab1994 Have you got any updates on this? |
@CaerusKaru any update on this? I'm facing the same issue in angular 9 |
I am facing the same issue, can you please update us on this please. |
I had the same issue until I realized that In my AppModule:
After that, everything worked like a charm. |
It works for me .Thanks. |
Ok another reason why this might fail: preboot uses the observable
These asynchronous tasks can be in your code (setTimeout, setInterval, or interval operator), or in any of your external libraries... making it very hard to debug. A solution is to manually do the cleanup:
This will make the replay of events, and then the cleanup of the server side application. You will be responsible for making sure that your app is loaded, otherwise you'll see a nice FOC when it switches from one app to the other... To help you detect pending async events such as document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(moduleInstance => {
// Ensure Angular destroys itself on hot reloads.
if (window['ngRef']) {
window['ngRef'].destroy();
}
window['ngRef'] = moduleInstance;
const ngZone = moduleInstance.injector.get(NgZone);
setInterval(() => {
const taskTrackingZone = (<any>ngZone)._inner.getZoneWith('TaskTrackingZone');
if (!taskTrackingZone) {
throw new Error(
`'TaskTrackingZone' zone not found! Have you loaded 'node_modules/zone.js/dist/task-tracking.js'?`
);
}
let tasks: any[] = taskTrackingZone._properties.TaskTrackingZone.getTasksFor('macroTask');
tasks = clone(tasks);
if (size(tasks) > 0) {
console.log('ZONE pending tasks', tasks);
}
}, 1000);
// Otherwise, log the boot error
})
.catch((error: string) => {
/* tslint:disable-next-line */
console.error(error);
});
}); And add |
Note: for support questions, please use the Universal Slack Channcel or https://gitter.im/angular/universal
Do you want to request a feature or report a bug?
Question/bug
What is the current behavior?
I'm having an issue with the application not working with
buffer
set to true. (works if I turn off buffer). What happens is that the visibleapp-root
is completely unusable while the hidden one withdisplay: none
works correctly. The pre-rendered version should be removed or hidden from the DOM once the client finishes bootstrapping, but in this case it doesn't happen.https://i.imgur.com/S8n4ctp.png
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
I only added
PrebootModule.withConfig({ appRoot: 'app-root' }),
to app.module andapplied a fix for the flickering issue mentioned Big FOUC as server side styles removed before the switch to client side #75 (comment)
What is the expected behavior?
It should remove the pre-rendered selector from the DOM after the client is finished bootstrapping.
What is the motivation / use case for changing the behavior?
I need help getting this fixed
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: