From e865759650e58011ffabf03464ee2e389f25a669 Mon Sep 17 00:00:00 2001 From: Bram Date: Fri, 4 Jul 2025 15:21:40 +0200 Subject: [PATCH] potential ram fix --- Dockers/puppeteer-api/app/utils/browser_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockers/puppeteer-api/app/utils/browser_utils.py b/Dockers/puppeteer-api/app/utils/browser_utils.py index 4e7d8b1..0a1a9d7 100644 --- a/Dockers/puppeteer-api/app/utils/browser_utils.py +++ b/Dockers/puppeteer-api/app/utils/browser_utils.py @@ -11,6 +11,8 @@ async def safe_browser_operation(url, operation_func): browser = None context = None page = None + playwright = None + try: # Get or create playwright instance playwright = await async_playwright().start() @@ -64,4 +66,10 @@ async def safe_browser_operation(url, operation_func): await browser.close() except Exception as e: print(f"Error closing browser: {e}") - # We don't re-raise here to avoid masking the original error \ No newline at end of file + + # Ensure playwright is closed properly - THIS IS THE KEY FIX + if playwright: + try: + await playwright.stop() + except Exception as e: + print(f"Error closing playwright: {e}") \ No newline at end of file