You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak: page.on() event listeners never removed on close #57
In local_browser.py, _attach_page_listeners() (line 370-372) registers page.on('console', ...) and page.on('pageerror', ...) handlers, but these are never removed in _close_async() (line 533).
The _close_async() method nullifies the self._page reference (line 541) but never calls page.remove_listener(). The Playwright pyee event emitter retains references to the bound methods, creating a memory leak.
Impact
Over long agent runs, listener references accumulate
Each listener closure captures the bound method, preventing GC
Memory grows linearly with agent steps
This is a known pattern - the Playwright Python repo has multiple confirmed reports of memory leaks from orphaned page.on() handlers
Suggested Fix
Store the listener removal in a cleanup list and call _detach_page_listeners() at the start of _close_async():
Activity