You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hydration & zoneless: elements got rerendered after Angular initializes #62672
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Hey,
I've noticed that on each page load, after Angular initializes, all element attributes get re-rendered. This is easy to see with the "Rendering -> Paint flashing" option enabled in dev tools & console.logs from mutation observer.
I've added an app initializer that blocks rendering for 1 second and registers a mutation observer to track all attribute changes:
provideAppInitializer(()=>{returnnewPromise((resolve)=>{if(typeofwindow!=='undefined'){// mutation observer for console.logs}setTimeout(()=>{resolve(true);},1000);});})
Hydration is the process that restores the server-side rendered application on the client. This includes things like reusing the server rendered DOM structures, persisting the application state, transferring application data that was retrieved already by the server, and other processes.
Do I understand correctly that in this case, hydration simply doesn't work?
Please provide a link to a minimal reproduction of the bug
This is probably a variant of #61231, the router outlet also relies on createComponent.
Take a look at console output: root ng-version (which is unrelated to app logic, router etc) gets re-rendered too (version changes from 20.1.1 to 20.1.1).
That means hydration doesn't work at all even with minimal setup in new project.
I've updated my repro: now i don't use router. Flicker & rerender still occurs as it was.
I verified that in dev mode angular reports that hydration was successful:
I've noticed that on each page load, after Angular initializes, all element attributes get re-rendered. This is easy to see with the "Rendering -> Paint flashing" option enabled in dev tools & console.logs from mutation observer.
The issue with the image is probably caused by the fact that you have devtools open and likely network cache is disabled, thus you are seeing a flicker on the image element (which is being re-fetched, even though the URL remains the same). @arturovt did an exploration earlier (see #52478 (comment)) and the problem with reloading in prod environment was only affecting <object>, <embed> and <iframe> elements.
Please let us know if you've noticed this issue in production environment as well or it only affects dev environment.
I've noticed that on each page load, after Angular initializes, all element attributes get re-rendered. This is easy to see with the "Rendering -> Paint flashing" option enabled in dev tools & console.logs from mutation observer.
The issue with the image is probably caused by the fact that you have devtools open and likely network cache is disabled, thus you are seeing a flicker on the image element (which is being re-fetched, even though the URL remains the same). @arturovt did an exploration earlier (see #52478 (comment)) and the problem with reloading in prod environment was only affecting <object>, <embed> and <iframe> elements.
Please let us know if you've noticed this issue in production environment as well or it only affects dev environment.
Yes. We noticed this in prod w/o dev tools opened and started to dig. We noticed that elements with @Animations are playing twice because attribute changes the same way i recorded in dev tools. I will update my repro again covering this too and will add block with stream of mutation observer updates to better understand what's going on
I ran both dev and prod locally, and hydration appears to be working. In dev I was able to confirm without changing anything that all the elements present have hydrated properly. I saw no issues with hydration in production mode either. There's the initial browser fetching of the image URL, but that's all I see otherwise.
Activity
atscott commentedon Jul 16, 2025
I believe this might be fixed by #62631. Can you update to 20.1.1 to see if the issue is resolved?
zip-fa commentedon Jul 16, 2025
Sorry, i gave invalid environment output, i am already on 20.1.1
atscott commentedon Jul 16, 2025
Ah, this is unrelated to zoneless.
JeanMeche commentedon Jul 16, 2025
This is probably a variant of #61231, the router outlet also relies on
createComponent.zip-fa commentedon Jul 17, 2025
Take a look at console output: root ng-version (which is unrelated to app logic, router etc) gets re-rendered too (version changes from 20.1.1 to 20.1.1).
That means hydration doesn't work at all even with minimal setup in new project.
zip-fa commentedon Jul 17, 2025
I've updated my repro: now i don't use router. Flicker & rerender still occurs as it was.
I verified that in dev mode angular reports that hydration was successful:
Code minimized to:
AndrewKushnir commentedon Jul 19, 2025
The issue with the image is probably caused by the fact that you have devtools open and likely network cache is disabled, thus you are seeing a flicker on the image element (which is being re-fetched, even though the URL remains the same). @arturovt did an exploration earlier (see #52478 (comment)) and the problem with reloading in prod environment was only affecting
<object>,<embed>and<iframe>elements.Please let us know if you've noticed this issue in production environment as well or it only affects dev environment.
zip-fa commentedon Jul 19, 2025
Yes. We noticed this in prod w/o dev tools opened and started to dig. We noticed that elements with @Animations are playing twice because attribute changes the same way i recorded in dev tools. I will update my repro again covering this too and will add block with stream of mutation observer updates to better understand what's going on
thePunderWoman commentedon Jul 22, 2025
I ran both dev and prod locally, and hydration appears to be working. In dev I was able to confirm without changing anything that all the elements present have hydrated properly. I saw no issues with hydration in production mode either. There's the initial browser fetching of the image URL, but that's all I see otherwise.
JeanMeche commentedon Jun 8, 2026
Is this still an issue ? (From Jess' comment, I would guess no).
zip-fa commentedon Jun 8, 2026
No, this was related to my another issue.
angular-automatic-lock-bot commentedon Jul 9, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.