question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Silent refresh causes unnecessary change detect

See original GitHub issue

Describe 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:

  1. Setup silent refresh
  2. Add something triggering window message event
  3. add a ngDoCheck to any component or directive with a console.log
  4. 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:open
  • Created 3 years ago
  • Reactions:9
  • Comments:11

github_iconTop GitHub Comments

3reactions
jeroenheijmanscommented, Sep 7, 2020

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.

2reactions
zampagecommented, Jul 7, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found