Silent refresh causes unnecessary change detect
See original GitHub issueDescribe the bug
When you have other parts of the application having iframes that are sending messages back to the parent window, silent refresh’s event listener on message
is causing angular to trigger its change detection.
Stackblitz example I can help setup if someone could point me to a seed stackblitz
To Reproduce Steps to reproduce the behavior:
- Setup silent refresh
- Add something triggering window
message
event - add a
ngDoCheck
to any component or directive with a console.log - watch it light up.
Expected behavior Should not have unnecessary change detect due to using silent refresh
Desktop (please complete the following information):
- OS: Windows
- Browser Chrome
- Version ^5.0.2
Additional context I reckon this should fix it; but then again I’m not sure if there’s any where else down the stream you’d need to run inside angular again.
this.ngZone.runOutsideAngular(() => {
window.addEventListener('message', this.silentRefreshPostMessageEventListener);
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:11
Top Results From Across the Web
angular-oauth2-oidc - Bountysource
Silent refresh causes unnecessary change detect $ 0. Created 2 years ago in manfredsteyer/angular-oauth2-oidc with 6 comments. Describe the bug. When you have ......
Read more >Why is authentication lost after refreshing my single page ...
There could be a few different reasons why authentication is lost after refreshing a single page application. Common reasons are 1) Auth0 ...
Read more >Silent refresh authenticates on OPTIONS preflight but not on ...
You were able to see 'HttpContext.User' because an iframe was opened up which allowed all necessary cookies to be sent. The user info...
Read more >Silent Refresh - Refreshing Access Tokens when using the ...
When using the implicit authentication flow refresh tokens cannot be requested or used, since the client application cannot be explicitly or ...
Read more >Persistent login in React using refresh token rotation
Refresh token rotation and refresh token reuse detection (which ... Storing refresh tokens via silent authentication involves sending a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Your remarks make sense to me. All that’s needed probably is for the maintainer to include the fix, or indicate that a PR for this is welcome. I know work on this library is typically done only every few months, and a couple at once then usually.
@kailo777 I’m aware that the same problem exists in other tools like Redux Dev Tools. We use the NgxsReduxDevToolsPlugin for NGXS, where we also opened an issue https://github.com/ngxs/store/issues/1758
But the problem also exists if we remove the Redux Dev Tools. As the author of this issue already stated, this problem comes from message eventlistener not running outside of angular zone. And there are apparently multiple packages that rely on the message events, hence generating the same problem.