playwright._impl._errors.TargetClosedError: Browser.new_page: Target page, context or browser has been closed
Been launching the chromium browser instance on my aws lambda with no issues until recently faced this kind of issue.
The browser fails to initialize and is causing my whole functionality down.
I’ve built the local image and tested it on docker, the app functions fine. This issue is only occuring on aws lambda
My browser launch configurations are :
async with async_playwright() as playwright:
browser_path = find_chromium_path()
executable_path = f"{browser_path}/chrome-linux/chrome"
# Local development
if not os.path.exists(executable_path):
executable_path = None
browser = await playwright.chromium.launch(headless=True,
executable_path=executable_path,
args=[
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--disable-gpu",
"--single-process",
"--no-zygote",
"--disable-audio-output",
"--disable-software-rasterizer",
"--disable-webgl",
"--disable-web-security",
"--disable-features=LazyFrameLoading",
"--disable-features=IsolateOrigins",
"--disable-background-networking"
]
)
Is there any workaround for this problem?
Shriyash Sutar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.