-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
With an SSR project, enabling POST requests cache transfer to avoid resending POSTrequest on the client side is only working when POST requests differ in their URLs (and not only in their body).
This repository provides a minimal reproduction.
The minimal example is deployed on this link.
I used a publicly available API to illustrate the problem. Two GraphQL requests, with the same URL, are being fired on the server-side. When hydration kicks in on the client-side, the same response body is restored for the both requests, leading to an error since data structures expected for each response do not match. Disabling Javascript (effectively blocking rehydration) renders the page correctly, with both a movie name and a character name.
A workaround is to add a dummy request param to one of the URLs, but this is not practical for real life projects where the number of requests can grow rapidly.
Please provide a link to a minimal reproduction of the bug
https://github.com/ahmadshahwan/angular-ssr-with-post-request-cache-transfer
Please provide the exception or error you saw
`main-L2QLRZ2I.js:7 ERROR TypeError: Cannot read properties of undefined (reading 'title')` in the clients console due to data structure mismatch between what is expected in the response body, and what is returned from the transferred cache.
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.1.3
Node: 21.2.0 (Unsupported)
Package Manager: npm 10.2.3
OS: linux x64
Angular: 17.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1701.3
@angular-devkit/build-angular 17.1.3
@angular-devkit/core 17.1.3
@angular-devkit/schematics 17.1.3
@schematics/angular 17.1.3
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.3
Anything else?
This issue was originally reported here (not by me), but it didn't seem to catch much attention.