Skip to content

RouterOutlet loads component 2x in a race condition #7497

@tbosch

Description

@tbosch

RouterOutlet#reuse checks if there is no current _componentRef and in that case creates a new component.
However, _componentRef is not set until the call to DynamicComponentLoader.loadNextToLocation is finished (in RouterOutlet#activate). If that call takes a bit longer (e.g. loading an html file from the server) RouterOutlet will create 2 instances of the component.

On my branch for codegen templates that changes the timing of DynamicComponentLoading a bit, the test for syncRoutesWithDynamicComponents (in sync_route_spec_impl.ts) fails because of this.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions