Skip to content

JS unleashProxy breaks Angular application with SSR rehydration (with workaround) #258

@DominikFra

Description

@DominikFra

Describe the bug

We have an angular app with Server Side Rendering and rehydration.
After including the unleash proxy and creating the UnleashClient on startup, angular writes into the console:

NG0506: Angular hydration expected the ApplicationRef.isStable() to emit true, but it didn't happen within 10000ms [...]

Problem is, that UnleashProxy internally uses a setInterval and therefore NgZone "isStable" event is never thrown

Steps to reproduce the bug

Description of the angular issue:
https://angular.dev/errors/NG0506

How to make it visible, that unleashProxy is in fact the problem:
angular/angular#52912 (comment)

Workaround: create the UnleashClient inside of an

ngZone.runOutsideAngular(() => {

Expected behavior

unleash proxy checks, if ngZone is being used and run's the code outside of ngZone
OR
The documentation is adapted to explain this to the user
OR
you find a different approach to fetch feature flags without a blocking macroTask

Logs, error output, etc.

Screenshots

No response

Additional context

No response

Unleash version

No response

Subscription type

None

Hosting type

None

SDK information (language and version)

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions