diff --git a/templates/js-crawlee-playwright-chrome/src/main.js b/templates/js-crawlee-playwright-chrome/src/main.js index 327c029a..0fdadac1 100644 --- a/templates/js-crawlee-playwright-chrome/src/main.js +++ b/templates/js-crawlee-playwright-chrome/src/main.js @@ -24,6 +24,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration(); const crawler = new PlaywrightCrawler({ proxyConfiguration, requestHandler: router, + launchContext: { + launchOptions: { + args: [ + '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers + ] + } + } }); await crawler.run(startUrls); diff --git a/templates/js-crawlee-puppeteer-chrome/src/main.js b/templates/js-crawlee-puppeteer-chrome/src/main.js index 415b4291..e656f940 100644 --- a/templates/js-crawlee-puppeteer-chrome/src/main.js +++ b/templates/js-crawlee-puppeteer-chrome/src/main.js @@ -20,6 +20,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration(); const crawler = new PuppeteerCrawler({ proxyConfiguration, requestHandler: router, + launchContext: { + launchOptions: { + args: [ + '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers + ] + } + } }); // Run the crawler with the start URLs and wait for it to finish. diff --git a/templates/python-crawlee-playwright/src/main.py b/templates/python-crawlee-playwright/src/main.py index 5fec2e42..eb2db84c 100644 --- a/templates/python-crawlee-playwright/src/main.py +++ b/templates/python-crawlee-playwright/src/main.py @@ -32,6 +32,9 @@ async def main() -> None: # Limit the crawl to max requests. Remove or increase it for crawling all links. max_requests_per_crawl=50, headless=True, + browser_options={ + 'args': ['--disable-gpu'], + } ) # Define a request handler, which will be called for every request. diff --git a/templates/python-playwright/src/main.py b/templates/python-playwright/src/main.py index 17cdc092..c8fa8621 100644 --- a/templates/python-playwright/src/main.py +++ b/templates/python-playwright/src/main.py @@ -50,7 +50,7 @@ async def main() -> None: # Launch Playwright and open a new browser context. async with async_playwright() as playwright: # Configure the browser to launch in headless mode as per Actor configuration. - browser = await playwright.chromium.launch(headless=Actor.config.headless) + browser = await playwright.chromium.launch(headless=Actor.config.headless, args=['--disable-gpu']) context = await browser.new_context() # Process the URLs from the request queue. diff --git a/templates/ts-crawlee-playwright-chrome/src/main.ts b/templates/ts-crawlee-playwright-chrome/src/main.ts index f5ef6e0b..4d536208 100644 --- a/templates/ts-crawlee-playwright-chrome/src/main.ts +++ b/templates/ts-crawlee-playwright-chrome/src/main.ts @@ -33,6 +33,13 @@ const crawler = new PlaywrightCrawler({ proxyConfiguration, maxRequestsPerCrawl, requestHandler: router, + launchContext: { + launchOptions: { + args: [ + '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers + ] + } + } }); await crawler.run(startUrls); diff --git a/templates/ts-crawlee-puppeteer-chrome/src/main.ts b/templates/ts-crawlee-puppeteer-chrome/src/main.ts index 880d7831..70177502 100644 --- a/templates/ts-crawlee-puppeteer-chrome/src/main.ts +++ b/templates/ts-crawlee-puppeteer-chrome/src/main.ts @@ -22,6 +22,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration(); const crawler = new PuppeteerCrawler({ proxyConfiguration, requestHandler: router, + launchContext: { + launchOptions: { + args: [ + '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers + ] + } + } }); // Run the crawler with the start URLs and wait for it to finish. diff --git a/templates/ts-playwright-test-runner/.actor/Dockerfile b/templates/ts-playwright-test-runner/.actor/Dockerfile index 3966bc48..27c07c56 100644 --- a/templates/ts-playwright-test-runner/.actor/Dockerfile +++ b/templates/ts-playwright-test-runner/.actor/Dockerfile @@ -1,4 +1,4 @@ -FROM apify/actor-node-playwright:20-1.37.1 +FROM apify/actor-node-playwright:22-1.49.1 COPY package*.json ./ diff --git a/templates/ts-playwright-test-runner/.dockerignore b/templates/ts-playwright-test-runner/.dockerignore index 05741991..81ef6a35 100644 --- a/templates/ts-playwright-test-runner/.dockerignore +++ b/templates/ts-playwright-test-runner/.dockerignore @@ -10,6 +10,7 @@ storage # generated test results playwright-report test-results.json +test-results # installed files node_modules diff --git a/templates/ts-playwright-test-runner/.gitignore b/templates/ts-playwright-test-runner/.gitignore index 7e53151b..ecf94982 100644 --- a/templates/ts-playwright-test-runner/.gitignore +++ b/templates/ts-playwright-test-runner/.gitignore @@ -8,3 +8,4 @@ dist playwright-report src/tests test-results.json +test-results/ diff --git a/templates/ts-playwright-test-runner/package.json b/templates/ts-playwright-test-runner/package.json index eb241387..a790480b 100644 --- a/templates/ts-playwright-test-runner/package.json +++ b/templates/ts-playwright-test-runner/package.json @@ -18,7 +18,7 @@ "dependencies": { "@apify/eslint-config-ts": "^0.3.0", "@apify/tsconfig": "^0.1.0", - "@playwright/test": "1.37.1", + "@playwright/test": "1.49.1", "@types/uuid": "^9.0.4", "apify": "^3.2.6", "tsx": "^4.6.2", diff --git a/templates/ts-playwright-test-runner/src/main.ts b/templates/ts-playwright-test-runner/src/main.ts index f17a6e42..2a6b2928 100644 --- a/templates/ts-playwright-test-runner/src/main.ts +++ b/templates/ts-playwright-test-runner/src/main.ts @@ -38,6 +38,11 @@ export default defineConfig({ colorScheme: '${darkMode ? 'dark' : 'light'}', locale: '${locale}', video: '${video}', + launchOptions: { + args: [ + '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers + ] + }, }, reporter: [ ['html', { outputFolder: '${getResultDir()}', open: 'never' }], diff --git a/templates/ts-playwright-test-runner/tests/first.spec.ts b/templates/ts-playwright-test-runner/tests/first.spec.ts index eaa57f10..902550dd 100644 --- a/templates/ts-playwright-test-runner/tests/first.spec.ts +++ b/templates/ts-playwright-test-runner/tests/first.spec.ts @@ -3,8 +3,12 @@ import { test, expect } from '@playwright/test'; test('has appropriate size', async ({ page }) => { let totalDownloaded = 0; - await page.on('response', async (r) => { - totalDownloaded += await (await r.body()).byteLength; + await page.on('response', (r) => { + r.body().then((b) => { + totalDownloaded += b.byteLength; + }).catch(() => { + // Ignore errors. + }); }); await page.goto('https://apify.com/about', { waitUntil: 'networkidle' });