Skip to content

Commit d7579f0

Browse files
authored
chore: bump ts-playwright-test-runner Playwright and Node version (#307)
Bumps the Playwright and Node versions in the template to `latest`s. Fixes the hanging `browserContext.newPage()` call by passing the `--disable-gpu` launch option to the browser.
1 parent 4848e7b commit d7579f0

File tree

12 files changed

+47
-5
lines changed

12 files changed

+47
-5
lines changed

templates/js-crawlee-playwright-chrome/src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
2424
const crawler = new PlaywrightCrawler({
2525
proxyConfiguration,
2626
requestHandler: router,
27+
launchContext: {
28+
launchOptions: {
29+
args: [
30+
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
31+
]
32+
}
33+
}
2734
});
2835

2936
await crawler.run(startUrls);

templates/js-crawlee-puppeteer-chrome/src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
2020
const crawler = new PuppeteerCrawler({
2121
proxyConfiguration,
2222
requestHandler: router,
23+
launchContext: {
24+
launchOptions: {
25+
args: [
26+
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
27+
]
28+
}
29+
}
2330
});
2431

2532
// Run the crawler with the start URLs and wait for it to finish.

templates/python-crawlee-playwright/src/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ async def main() -> None:
3232
# Limit the crawl to max requests. Remove or increase it for crawling all links.
3333
max_requests_per_crawl=50,
3434
headless=True,
35+
browser_options={
36+
'args': ['--disable-gpu'],
37+
}
3538
)
3639

3740
# Define a request handler, which will be called for every request.

templates/python-playwright/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def main() -> None:
5050
# Launch Playwright and open a new browser context.
5151
async with async_playwright() as playwright:
5252
# Configure the browser to launch in headless mode as per Actor configuration.
53-
browser = await playwright.chromium.launch(headless=Actor.config.headless)
53+
browser = await playwright.chromium.launch(headless=Actor.config.headless, args=['--disable-gpu'])
5454
context = await browser.new_context()
5555

5656
# Process the URLs from the request queue.

templates/ts-crawlee-playwright-chrome/src/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ const crawler = new PlaywrightCrawler({
3333
proxyConfiguration,
3434
maxRequestsPerCrawl,
3535
requestHandler: router,
36+
launchContext: {
37+
launchOptions: {
38+
args: [
39+
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
40+
]
41+
}
42+
}
3643
});
3744

3845
await crawler.run(startUrls);

templates/ts-crawlee-puppeteer-chrome/src/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
2222
const crawler = new PuppeteerCrawler({
2323
proxyConfiguration,
2424
requestHandler: router,
25+
launchContext: {
26+
launchOptions: {
27+
args: [
28+
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
29+
]
30+
}
31+
}
2532
});
2633

2734
// Run the crawler with the start URLs and wait for it to finish.

templates/ts-playwright-test-runner/.actor/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM apify/actor-node-playwright:20-1.37.1
1+
FROM apify/actor-node-playwright:22-1.49.1
22

33
COPY package*.json ./
44

templates/ts-playwright-test-runner/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ storage
1010
# generated test results
1111
playwright-report
1212
test-results.json
13+
test-results
1314

1415
# installed files
1516
node_modules

templates/ts-playwright-test-runner/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist
88
playwright-report
99
src/tests
1010
test-results.json
11+
test-results/

templates/ts-playwright-test-runner/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@apify/eslint-config-ts": "^0.3.0",
2020
"@apify/tsconfig": "^0.1.0",
21-
"@playwright/test": "1.37.1",
21+
"@playwright/test": "1.49.1",
2222
"@types/uuid": "^9.0.4",
2323
"apify": "^3.2.6",
2424
"tsx": "^4.6.2",

0 commit comments

Comments
 (0)