Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Angular Prerendering routes twice resulting in 2 transfer state script Tags and 2 "prerendered"-Comments #2334

@Jeremias-Nater

Description

@Jeremias-Nater

🐞 Bug report

What modules are related to this issue?

  • builders
  • express-engine
  • TransferState
  • universal

Description

Double Prerender

When providing routes to prerender, Angular starts prerendering my files twice starting from some point
End of prerendered file:
image

🔬 Minimal Reproduction

You can download the Project that i created to reproduce the problem here from my github

in my project run:

  • npm i
  • npm run prerender
  • check /dist/browser/detail/20 (The problem isn't there initially so at /dist/browser/detail/1 everything works fine for me)
  • the file now should have 2 comments and 2 app state script tags at the end

to create this reproduction i did the following:

  • Download finished tour of heroes example from https://angular.io/guide/universal
  • add ServerTransferStateModule / BrowserTransferState Modules to the corresponding "app.server.module.ts" / "app.module.ts"
  • create routes.txt file with routes to /detail/1-20
  • mention routes.txt file in angular.json in options of prerender script (angular.json:169)

🔥 Exception or Error

While in the minimal reproduction i did not provide any transfer state, in my real app the transferstate is set. The big issue now is that the first script tag with the same id is always empty which causes transferState to be useless essentially and the request to be made again

🌍 Your Environment

Angular CLI: 12.1.4
Node: 14.17.6
Package Manager: npm 6.14.15
OS: linux x64

Angular: 12.1.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.4
@angular-devkit/build-angular   12.1.4
@angular-devkit/core            12.1.4
@angular-devkit/schematics      12.1.4
@angular/cli                    12.1.4
@nguniversal/builders           12.1.0
@nguniversal/express-engine     12.1.0
@schematics/angular             12.1.4
rxjs                            6.6.7
typescript                      4.3.5


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions