Sparticuz / chromium

Chromium (x86-64) for Serverless Platforms
MIT License
1.02k stars 69 forks source link

[BUG] browserType.launch: Target page, context or browser has been closed #286

Open arbengers opened 4 months ago

arbengers commented 4 months ago

Environment

Expected Behavior

Launch the browser, chromium

Current Behavior

Error: browserType.launch: Target page, context or browser has been closed

<launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-domain-reliability --disable-print-preview --disable-speech-api --disk-cache-size=33554432 --mute-audio --no-default-browser-check --no-pings --single-process --font-render-hinting=none --disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,site-per-process --enable-features=NetworkServiceInProcess2,SharedArrayBuffer --hide-scrollbars --ignore-gpu-blocklist --in-process-gpu --window-size=1920,1080 --use-gl=angle --use-angle=swiftshader --allow-running-insecure-content --disable-setuid-sandbox --disable-site-isolation-trials --disable-web-security --no-sandbox --no-zygote --headless='shell' --user-data-dir=/tmp/playwright_chromiumdev_profile-XXXXXXENN9kd --remote-debugging-pipe --no-startup-window

Steps to Reproduce

import chromium from '@sparticuz/chromium';
import { chromium as chromiumPw } from 'playwright-core';

async handleMessage(records: any) {
        for (const record of records) {
            console.log(`Cognito Data: ${JSON.stringify(data)}`);
            try {
               const browser = await chromiumPw.launch({
                    headless: true,
                    args: chromium.args,
                    executablePath: await chromium.executablePath(),
                });
                const context = await browser.newContext();
                const page = await context.newPage();
                await page.goto('https://some_domain.com');
                // HTML Content
                const pageContent = await page.content();
                // Text Content
                const textContent = await page.evaluate(() => document.body.innerText);

            } catch (err) {
                console.log(err);
            }
        }
    }
gscpw commented 1 month ago

Any workarounds?

gscpw commented 1 month ago

I have downgraded to @sparticuz/chromium v123 and playwright-core at ~1.42.0 and I no longer experience this issue.

xmimiex commented 56 minutes ago

Nothing else to do ? we can't use the latest versions ?