-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Control flow with defer inside does not clean up before httpClient ends its request #56992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a hydration "issue". |
Can this behavior be turned off on client side? I propose to disable ExperimentalPendingTasks for HttpClient on client side to fix this |
This is not related to defer. We should review the hydration strategy when it comes to view containers that have different views on client and server. |
@zip-fa looking at the video that you've shared and the code, Angular seems to work as expected. The "Loading..." text that you see when you load the page is coming from the |
I understand how it works, but this behavior slightly differs from the previous version: the HTTP client in v17 does not contribute to app stability, and blocks disappear instantly. The only way to ‘fix this’ is to send all queries on the server side, so the client app will catch up with the response from the transfer state. |
We did discuss this during triage, this not a defer blug but a hydration one. if/else block aren't handled correctly.
If foo generated client side and both are kept until the hydration cleanup.
|
@JeanMeche all unclaimed dehydrated views as removed during the post-hydration cleanup (that's the goal of the cleanup). There might be a period of time when both branches are visible on a page, but the post-hydration cleanup should remove one of the branches and it looks like it's happening (if I understand the comment correctly). Just want to confirm: do you see that the if-else block gets into the correct state, just not immediately? |
Quick update: there were some hydration cleanup fixes landed in v18.2.0. @zip-fa could you please try to update your app and check if there were any changes in hydration behavior in your use-case? |
Sure thing! Will try new version tomorrow early |
The issue still persists on v18.2 |
Hey guys. Just saw tweet about i18n hydration. Is there any chances this gets fixed?😔 |
@zip-fa I've looked at provided repro and noticed the following hydration behavior on the client:
The cleanup intentionally happens once an application becomes stable (e.g. when there is no pending work), but not immediately, since application state may change as a result of the pending work. Removing unclaimed views earlier may result in flickering on a page (for ex. if a |
To make application behave similar on server & client side, we need to send requests inside SSR environment with user's JWT token. Currently, it's possible to do that in production build (intercept cookies via middleware on express side & provide JWT token as injection token), but it's not possible to do the same on local dev server. Is there a way to intercept request in dev environment (vite) with some kind of middleware @AndrewKushnir? If yes, this issue does not make sense |
@zip-fa I believe it should be possible once PR angular/angular-cli#28463 lands (cc @alan-agius4 to confirm). |
That is correct @AndrewKushnir. |
Waiting to try v19 then 🙏🏻 |
On v19 this is no longer an issue - we can fully sync Client & Server rendering. |
Please, solve this in version 18.2 |
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. |
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
Hi. I noticed that defer's @Loading block is not cleaned up before HttpClient completes its request. In v17 it doesn't wait for it.
Demo video:
ng-bug.mov
Full component code which reproduces the issue:
Please provide a link to a minimal reproduction of the bug
https://github.com/zip-fa/ng18-defer-cleanup-issue
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: