-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are the source of the bug?
platform-server
Is this a regression?
Yes
Description
Until v13.3.x there wasn't any check before serializing TransferState in order to be rendered as part of the document.
In v14.1.x a check has been introduced to verify if TransferState.store has any keys (https://github.com/angular/angular/blob/14.1.x/packages/platform-server/src/transfer_state.ts#L26), otherwise no serialization will happen at all.
This now leads to no TransferState data being added to server-side rendered document, if for adding data to the store TransferState.onSerialize() is being used instead of TransferState.set().
The advantage of using TransferState.onSerialize() I see is, that applied callback will be invoked short before SSR is finished instead of somewhere at the beginning or during the app lifecycle on server side. So if data to be transferred would change in this period, it'd be more safe doing a late serialization.
Am I missing something or didn't I understand correctly how to add data to TransferState by using onSerialize?
Anyway, as behavior now changed because of that "empty store" check I see this as a regession, which has to be fixed.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
no TransferState data being added to SSR document
Please provide the environment you discovered this bug in (run ng version)
Node : 16.14.2
OS : linux x64
npm : 8.5.0
nx : 14.5.4
@nrwl/angular : 14.5.4
"@angular/animations": "14.1.1",
"@angular/cdk": "14.1.1",
"@angular/common": "14.1.1",
"@angular/compiler": "14.1.1",
"@angular/core": "14.1.1",
"@angular/forms": "14.1.1",
"@angular/google-maps": "14.1.1",
"@angular/localize": "14.1.1",
"@angular/platform-browser": "14.1.1",
"@angular/platform-browser-dynamic": "14.1.1",
"@angular/platform-server": "14.1.1",
"@angular/router": "14.1.1",
Anything else?
No response