fix: network task handles leak#3053
Closed
Gby56 wants to merge 1 commit intomicrosoft:mainfrom
Closed
Conversation
Author
|
@microsoft-github-policy-service agree |
Member
|
We're not accepting failing test cases without a fix. |
Author
|
@Skn0tt could i get at least a confirmation to whether the issue seems valid on your end, before i provide a fix ? I'm willing to help but I don't know all the internals here, I have just observed the problem regularly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello 😄
Given several reports of memory leaks, and my personal experience of long-running contexts getting bloated after some time, leading to OOM problems, I wanted to investigate a bit with some help from Codex (and my personal investigation)
I added a failing test case to start
Findings
never cancels the page-close task when the response wins. I reproduced this with a local micro-check: normal finish leaves one pending close-watch task attached to the page close
future.
_child_ws_connections at playwright/_impl/_browser_type.py:291, but nothing removes it. playwright/_impl/_connection.py:327 also does not clear _objects, so a retained closed child can
keep its object graph alive.
pending futures or clear listeners. This is risky for long-running route/request handlers, because route events are scheduled as tasks in playwright/_impl/_page.py:287 and active route
invocations retain routes in playwright/_impl/_helper.py:416. This matches the shape of GitHub issue [BUG] hang when node is crash or killed #1779 ([BUG] hang when node is crash or killed #1779).
ywright/_impl/_fetch.py:516, and the official docs state the body remains in memory until dispose/context close: https://playwright.dev/python/docs/api/class-apiresponse. In a long-li
ved context, missing await response.dispose() after route.fetch() is enough to look like a leak.
est in tests/test_reference_count_async.py:78, but playwright/_impl/_tracing.py:68 increments global tracing state before tracing_started() completes, and playwright/_impl/_tracing.py
:86 is not exception-safe around local zip/export cleanup. That lines up with trace-stop hang reports like [BUG] Hanging when browser runs out of memory #1847 ([BUG] Hanging when browser runs out of memory #1847).