Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting signal outside of angular zone error #55569

Closed
robertIsaac opened this issue Apr 27, 2024 · 3 comments
Closed

setting signal outside of angular zone error #55569

robertIsaac opened this issue Apr 27, 2024 · 3 comments

Comments

@robertIsaac
Copy link
Contributor

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

when updating signal outside of Angular zone, it doesn't reflect in the Angular app which produce very hard to debug bugs

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-amkub7?file=src%2Fmain.ts

Please provide the exception or error you saw

it shows `Hello from Angular!` instead of `Hello from Rob!`

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.6
Node: 20.11.0
Package Manager: npm 10.4.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.6
@angular-devkit/build-angular   17.3.6
@angular-devkit/core            17.3.6
@angular-devkit/schematics      17.3.6
@schematics/angular             17.3.6
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.4

Anything else?

workaround is to run effect that does nothing but read the signal fixes the problem

effect(() => {
  this.name();
});

this error happen in both default and push detect changes strategy

@JeanMeche
Copy link
Member

JeanMeche commented Apr 27, 2024

This is a known issue and being adressed in v18 with the new hybrid change detection scheduling. The new feature is opt-out, meaning by default every v18 apps will trigger CD on signal update even when happening outside the zone.

The opt-out to return to pre-v18 behavior will be accessible via provideZoneChangeDetection({ ignoreChangesOutsideZone: true }).

You can already try this is the latest pre-release.

@robertIsaac
Copy link
Contributor Author

This is a known issue and being adressed in v18 with the new hybrid change detection scheduling. The new feature is opt-out, meaning by default every v18 apps will trigger CD on signal update even when happening outside the zone.

The opt-out to return to pre-v18 behavior will be accessible via provideZoneChangeDetection({ ignoreChangesOutsideZone: true }).

You can already try this is the latest pre-release.

sorry to bother you then, I tried to search first but couldn't see a reported issue about it

@JeanMeche
Copy link
Member

The umbrella issue is #53844, feel free to have a look at it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants