Repository navigation
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
When using Incremental Hydration, the below code works but subsequent code throws error on client side navigation to this page from another page:
This works:
@if (pageHeading() && !isLoggedIn()) {
@defer(hydrate when isLoggedIn()) {
<div class="mat-card p15 pb7 mb10">
<h1 class="mb10">{{pageHeading()}}</h1>
<p class="mb10 paragraph">{{pageDescription()}}</p>
</div>
}
}
This doesn't work:
@defer(hydrate when isLoggedIn()) {
@if (pageHeading() && !isLoggedIn()) {
<div class="mat-card p15 pb7 mb10">
<h1 class="mb10">{{pageHeading()}}</h1>
<p class="mb10 paragraph">{{pageDescription()}}</p>
</div>
}
}
Error
core.mjs:7283 ERROR TypeError: Cannot read properties of undefined (reading 'p')
at findFirstKnownParentDeferBlock (core.mjs:22378:54)
at core.mjs:22414:7
at Generator.next (<anonymous>)
at chunk-4MWRP73S.js?v=7a14075d:76:61
at new ZoneAwarePromise (zone.js:2702:25)
at __async (chunk-4MWRP73S.js?v=7a14075d:60:10)
at hydrateFromBlockNameImpl (core.mjs:22403:91)
at core.mjs:22445:16
at Generator.next (<anonymous>)
at chunk-4MWRP73S.js?v=7a14075d:76:61
Similarly when using the second code block, incremental hydration works as expected on hard page load i.e. when isLoggedIn() is true, this div gets removed. But that doesn't seem to be the case with the first code block.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
core.mjs:7283 ERROR TypeError: Cannot read properties of undefined (reading 'p')
at findFirstKnownParentDeferBlock (core.mjs:22378:54)
at core.mjs:22414:7
at Generator.next ()
at chunk-4MWRP73S.js?v=7a14075d:76:61
at new ZoneAwarePromise (zone.js:2702:25)
at __async (chunk-4MWRP73S.js?v=7a14075d:60:10)
at hydrateFromBlockNameImpl (core.mjs:22403:91)
at core.mjs:22445:16
at Generator.next ()
at chunk-4MWRP73S.js?v=7a14075d:76:61
Please provide the environment you discovered this bug in (run ng version)
@angular-devkit/architect 0.1900.0-next.13
@angular-devkit/build-angular 19.0.0-next.13
@angular-devkit/core 18.2.4
@angular-devkit/schematics 18.2.4
@angular/cdk 19.0.0-next.10
@angular/cli 19.0.0-next.13
@angular/fire 18.0.1
@angular/google-maps 19.0.0-next.10
@angular/material 19.0.0-next.10
@angular/pwa 19.0.0-next.13
@angular/ssr 19.0.0-next.13
@schematics/angular 18.2.4
rxjs 7.8.1
typescript 5.6.2
zone.js 0.15.0
Anything else?
No response
Activity
naveedahmed1 commentedon Oct 25, 2024
cc @thePunderWoman @AndrewKushnir
naveedahmed1 commentedon Oct 25, 2024
Maybe its not just about client side navigation, I am seeing similar error for cases like when i have:
And
applyFormIsOpensignal is updated through some action e.g.:thePunderWoman commentedon Oct 25, 2024
It is definitely client side navigation related where hydrate triggers are attempting to fire at the wrong time. The fix should land on Monday.
naveedahmed1 commentedon Oct 25, 2024
This was pretty quick! Thank you so much, enjoy your weekend.
12 remaining items
AndrewKushnir commentedon Oct 26, 2024
You may try patching corresponding file in the
node_modulesdirectly and rebuild the project. Note: you'd also need to clear the build cache by runningng cache cleanbefore rebuilding the project.naveedahmed1 commentedon Oct 26, 2024
It seems that
ng cache cleanactully fixed the issue, I think I misedng cache cleanstep when updating packages to https://github.com/angular/angular/actions/runs/11523797513/artifacts/2105790303naveedahmed1 commentedon Oct 26, 2024
Although I am no longer seeing that error message in console. But it seems that Incremental Hydration isn't working with
ng buildoutput when deployed.For example I have a form with
@defer(hydrate on interaction)and when runningng serve, interaction with form input fields hydrate it, i.e. ngb="d8" attribute gets removed.But when using
ng buildand deploying, the hydration doesnt work, it doesnt throw errors, but doesnt remove ngb="d8" attribute either. And form submit starts hard navigation.I think its the same behavior that I reported during the initial testing of partial hydration.
naveedahmed1 commentedon Oct 27, 2024
To me more specific:
Below triggers are not working when deployed:
Whereas below seems to be working fine:
naveedahmed1 commentedon Oct 28, 2024
Let me share another case, since it seems related:
I have a jobs list component:
In the jobs list component I have an ad unit with hydrate never:
This throw error on directly visiting the jobs list page or on hard reload (i.e. with SSR response):
My understanding is, on hydration of
jobs-listcomponent, the ad unit code should remain untouched, since its enclosed inhydrate neverblock. But it seems that its being updated as well, thats why, adsense is throwing error.fix(core): Prevents trying to trigger incremental hydration on CSR (#…
fix(core): Prevents trying to trigger incremental hydration on CSR (a…
naveedahmed1 commentedon Oct 29, 2024
@alan-agius4 can you please create a new project using Cloudflare Pages Angular template, add incremental hydration with below triggers, deploy it and see if it works fine on your side?
timer
hover
interaction
when
ref: #58359 (comment)
thePunderWoman commentedon Oct 29, 2024
@naveedahmed1 With your supplemental issues, can you please create a new issue per item focused on each individual issue as a bug for us? And then with each, we really need a minimal reproduction rather than using your application. Your app has such a custom setup that it makes it more difficult to diagnose what's going on. Each individual bug will help us track these and address them faster. Thanks for the help!
angular-automatic-lock-bot commentedon Nov 29, 2024
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.