Playwright Browser Launch Failure: Deprecated Headless Mode in Chrome

Anyone know how to fix this error? Works perfectly locally, but not on the Apify platform. See file attached with full error log. Code snippet:
import { PlaywrightCrawler, Dataset } from 'crawlee';

const crawler = new PlaywrightCrawler({
preNavigationHooks: [
async ({ page, request, log }) => {
if (playwrightCookies.length > 0) {
log.info(`Setting ${playwrightCookies.length} cookies for ${request.url}...`);
await page.context().addCookies(playwrightCookies);
}
},
],
launchContext: {
launchOptions: {
headless: true,
},
},
async requestHandler({ page, request, log }) {
log.info(`Processing ${request.url}...`);

const startTime = Date.now();

if (waitForSelector) {
try {
await page.waitForSelector(waitForSelector, { timeout: 60000 });
} catch (error) {
log.info(`Selector "${waitForSelector}" not detected after 1 minute. Continuing...`);
}
}
import { PlaywrightCrawler, Dataset } from 'crawlee';

const crawler = new PlaywrightCrawler({
preNavigationHooks: [
async ({ page, request, log }) => {
if (playwrightCookies.length > 0) {
log.info(`Setting ${playwrightCookies.length} cookies for ${request.url}...`);
await page.context().addCookies(playwrightCookies);
}
},
],
launchContext: {
launchOptions: {
headless: true,
},
},
async requestHandler({ page, request, log }) {
log.info(`Processing ${request.url}...`);

const startTime = Date.now();

if (waitForSelector) {
try {
await page.waitForSelector(waitForSelector, { timeout: 60000 });
} catch (error) {
log.info(`Selector "${waitForSelector}" not detected after 1 minute. Continuing...`);
}
}
2 Replies
Hall
Hall2mo ago
Someone will reply to you shortly. In the meantime, this might help:
Louis Deconinck
Louis DeconinckOP2mo ago
I actually had this problem before with a different scraper: https://discord.com/channels/801163717915574323/1337487080527368212/1337487080527368212 In my package.json I set "playwright": "1.49.1" instead of "playwright": "*" like @serge recommended on the other thread and that solves the problem. Probably something the Apify team should look into so the Apify platform can work with the latest versions of Playwright.

Did you find this page helpful?