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
fix: prevent ProtocolCallback memory leak during tracing (#2977)
Fix memory leak where ProtocolCallback objects accumulated when tracing
was enabled. The issue affected both sync and async Playwright, but was
more severe in async usage where callbacks persisted permanently.
- When tracing is enabled, send_no_reply() creates ProtocolCallback objects
- These callbacks have circular references via task cancellation handlers
- For no_reply messages, futures are never resolved, preventing GC cleanup
- Each page operation during tracing leaked ~10 callbacks permanently
- Add no_reply parameter to ProtocolCallback constructor
- For no_reply=True: skip cancellation setup and resolve future immediately
- For no_reply=False: use full constructor with cancellation handling
- Update dispatch() to handle missing callbacks gracefully
- Added regression test in test_reference_count_async.py
- Test fails before fix (30+ leaked callbacks) and passes after (≤5)
- All existing tracing and asyncio tests continue to pass
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
0 commit comments