cypress
cypress copied to clipboard
Potential memory leak in CriClient
Test code to reproduce
N/A
Cypress Mode
both modes
Cypress Version
13.12.0
Browser Version
Node version
Operating System
Memory Debug Logs
No response
Other
In the connect
method of CriClient
(packages/server/lib/browsers/cri-client.ts
), several event listeners are added to the newly created CDPClient
. These event listeners are never removed, and reference the CDPClient
that they are attached to via closure. Since they are not removed, the reference to the CDPClient
is circular: even when the CDPClient
is disconnected and replaced with a new CDPClient
, the there are still references to the old CDPClient
in its event listeners, so cannot be garbage collected.
To fix, remove any self-referential listeners on cri
when it is closed.