AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
582 stars 160 forks source link

Communication with Service Worker causes memory leak #1395

Closed radk0s closed 3 months ago

radk0s commented 3 months ago

Issue and Steps to Reproduce

Issue is reproducible on demo deployment https://icy-glacier-004ab4303.2.azurestaticapps.net/. When you log-in and app is opened for few minutes memory usage is increasing. It can be checked in Chrome Dev Tools/Memory panel.

Versions

7.22.8

Screenshots

Screenshot 2024-07-01 at 10 15 45

Expected

When app is open (no actions), memory usage is not increasing over time.

Actual

I did few memory snapshots and noticed that most of new memory allocations are coming from MessagePort class. After digging into oidc-client code I found this util used for Service Worker communication which creates MessageChannel but it's never closed after promise resolution.

Additional Details

guillaume-chervet commented 3 months ago

Thank you very much @radk0s

guillaume-chervet commented 3 months ago

hi @radk0s version 7.22.9 contains your fix!

radk0s commented 3 months ago

Great, thanks @guillaume-chervet! Already checked and issue is gone.