Skip to content

Recurring bug: "wrong origin" console.log() calls again cause memory leaks! #790

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

Open
Maximaximum opened this issue Apr 10, 2020 · 3 comments
Labels
investigation-needed Indication that the maintainer or involved community members may need to investigate more.

Comments

@Maximaximum
Copy link
Contributor

This bug is closely related to #616.

The original cause of the memory leak (reported in #616) was fixed, but immediately another cause was introduced (for whatever cause?) by the commit 4bf8901#diff-fbc8c2d288ee2f0a2a9d42a46e5292bd

See this line:

Whenever any message (!) is posted by any source (!), the whole MessageEvent is being logged into the console. Which basically means that references to the huge source and target objects are forever stored in the console for no reason. This, in turn, means that these resources can never be freed by the garbage collector!

The fix would be trivial: the event object should not be logged to the console.

However, IMO it makes no sense to log anything at all to the console whenever ANY source posts ANY message. Logging should ONLY be utilized for messages that are related to oidc and this library. Other messages should be completely ignored.

Severity
In applications that only use postMessage() for authentication messages within oauth, this bug does not cause any issues. But in applications that heavily use postMessage() calls and create/destroy multiple iframes over their lifetime, this is an extremely critical issue that easily causes the whole application to fail.

@Maximaximum
Copy link
Contributor Author

Seems like this issue has initially been reported by #447, though that bug report didn't include the aspect that logging event objects causes memory leaks

@Maximaximum
Copy link
Contributor Author

FWIW, the real problem is that, for example, this issue affects ANY application that uses angular-oauth-oidc in conjunction with ngrx and @ngrx/store-devtools, because @ngrx/store-devtools uses postMessage() to broadcast each and every ngrx action being dispatched. So, effectively this means that each action dispatched within the application will be logged into the console. Which, in turn, means that any object referenced by the action object (and the MessageEvent) will never be garbage collected

@jeroenheijmans jeroenheijmans added the investigation-needed Indication that the maintainer or involved community members may need to investigate more. label Aug 3, 2020
@ntyrrell
Copy link

Are there any updates on this issue? It would be great to not have this library interfere with @ngrx/store-devtools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation-needed Indication that the maintainer or involved community members may need to investigate more.
Projects
None yet
Development

No branches or pull requests

3 participants