Skip to content

The TransferState doesn't render the data script after a HTTP Request #49425

@GeorgeHulpoi

Description

@GeorgeHulpoi

🐞 Bug report

What modules are related to this issue?

  • builders
  • common
  • express-engine

Is this a regression?

Yes, the previous version in which this bug was not present was:
13.2.0

Description

I'm trying in a lazy module to execute an HTTP Request. The HTTP Request is executed on the server platform, and the value is set to the TransferState, but the data which should be in a script at the end of the document is not present. Consequently, on the browser platform, the same HTTP Request is executed once more. The same script works on a non-loaded lazy module.

🔬 Minimal Reproduction

  1. Create a blank repository: ng new test
  2. Add Angular Universal: ng add @nguniversal/express-engine
  3. Create a lazy module with RouterModule and add HttpClientModule into it.
  4. Check if the TransferState has StateKey, if yes, retrieve with TransferState.get, else make the HTTP Request and TransferState.set the response.

A reproduction of the issue is here: https://github.com/GeorgeHulpoi/angular-universal-transfer-state-issue

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.0.4
Node: 16.17.0
Package Manager: npm 9.2.0
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1500.4 (cli-only)
@angular-devkit/core         15.0.4 (cli-only)
@angular-devkit/schematics   15.0.4 (cli-only)
@schematics/angular          15.0.4 (cli-only)

Metadata

Metadata

Assignees

Labels

area: common/httpIssues related to HTTP and HTTP Clientarea: serverIssues related to server-side rendering

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions