System info
- Playwright Version: v1.40.0
- Operating System: All
- Browser: Chromium
- Other info: 32GB RAM
Source code
from playwright.sync_api import sync_playwright
print("Starting...")
with sync_playwright() as p:
try:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
for index in range(10000):
print("Iteration:", index)
page.goto('https://google.com')
except Exception as error:
if page:
print("Error: ", {error})
page.screenshot(path='error.png', timeout=0)
print("Took a screenshot")
Link to the GitHub repository with the repro
Test file (self-contained)
Steps
- Run the code
- Wait until the for loop crashes at about 2000-3000 iterations
Expected
The for loop runs all the way through and not crash.
The page.screenshot runs normally.
Actual
At the 2652 iteration, a Timeout exception gets caught. Chrome gets an Out of Memory error.
The code hangs at the page.screenshot line and never completes.
Screenshot

System info
Source code
Link to the GitHub repository with the repro
Test file (self-contained)
Steps
Expected
The for loop runs all the way through and not crash.
The
page.screenshotruns normally.Actual
At the 2652 iteration, a Timeout exception gets caught. Chrome gets an Out of Memory error.
The code hangs at the
page.screenshotline and never completes.Screenshot