Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

chore: camoufox-cloudflare e2e + camoufox-ts template on Playwright 1.60 (#3749)

Martin Adámek0483e17bf34a
diff --git a/packages/templates/templates/camoufox-ts/Dockerfile b/packages/templates/templates/camoufox-ts/Dockerfile
index f33195aed..77c6991a1 100644
--- a/packages/templates/templates/camoufox-ts/Dockerfile
+++ b/packages/templates/templates/camoufox-ts/Dockerfile
@@ -1,7 +1,7 @@
# Specify the base Docker image. You can read more about
# the available images at https://crawlee.dev/docs/guides/docker-images
# You can also use any other image from Docker Hub.
-FROM apify/actor-node-playwright-camoufox:24-1.58.2 AS builder
+FROM apify/actor-node-playwright-camoufox:24-1.60.0 AS builder
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
@@ -19,7 +19,7 @@ COPY --chown=myuser . ./
RUN npm run build
# Create final image
-FROM apify/actor-node-playwright-camoufox:24-1.58.2
+FROM apify/actor-node-playwright-camoufox:24-1.60.0
# Copy only built JS files from builder image
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
diff --git a/packages/templates/templates/camoufox-ts/package.json b/packages/templates/templates/camoufox-ts/package.json
index 47c2c805d..4d4f4bcea 100644
--- a/packages/templates/templates/camoufox-ts/package.json
+++ b/packages/templates/templates/camoufox-ts/package.json
@@ -8,7 +8,7 @@
"@crawlee/impit-client": "^3.0.0",
"camoufox-js": "^0.11.0",
"crawlee": "^3.0.0",
- "playwright": "1.61.0"
+ "playwright": "1.60.0"
},
"devDependencies": {
"@apify/tsconfig": "^0.1.0",
diff --git a/renovate.json b/renovate.json
index 48ab84595..79085fdd4 100644
--- a/renovate.json
+++ b/renovate.json
@@ -26,6 +26,14 @@
"groupSlug": "all-non-major",
"automerge": true,
"automergeType": "branch"
+ },
+ {
+ "description": "camoufox-js dictates the compatible Playwright/Firefox build; do not bump Playwright in the Camoufox template until Camoufox supports the newer version",
+ "matchFileNames": [
+ "packages/templates/templates/camoufox-ts/package.json"
+ ],
+ "matchPackageNames": ["playwright"],
+ "enabled": false
}
],
"schedule": ["every weekday"],
diff --git a/test/e2e/camoufox-cloudflare/actor/Dockerfile b/test/e2e/camoufox-cloudflare/actor/Dockerfile
index 5e76e31c9..2c6befacb 100644
--- a/test/e2e/camoufox-cloudflare/actor/Dockerfile
+++ b/test/e2e/camoufox-cloudflare/actor/Dockerfile
@@ -1,23 +1,23 @@
-FROM apify/actor-node-playwright-camoufox:24-1.58.2-beta AS builder
+# The base image provides the Camoufox binary (Firefox 150); the actor pins the matching
+# Playwright (1.60) in package.json. Camoufox-js 0.11 cannot run under Playwright 1.61.
+FROM apify/actor-node-playwright-camoufox:24-1.60.0-beta
-COPY /packages ./packages
-COPY /package*.json ./
+# The Camoufox base image builds as the non-root `myuser`, so everything we copy in must
+# be chowned to it — otherwise `npm install`/`npm update` cannot write into the workspace
+# packages (EACCES on packages/*/node_modules).
+COPY --chown=myuser packages ./packages
+COPY --chown=myuser package*.json ./
+
+# `--ignore-scripts` skips the `camoufox-js fetch` postinstall; the browser is already
+# baked into the base image.
RUN npm --quiet set progress=false \
&& npm install --only=prod --no-optional --no-audit --ignore-scripts \
- && npm update
-
-FROM apify/actor-node-playwright-camoufox:24-1.58.2-beta
-
-RUN rm -r node_modules
-COPY --from=builder /node_modules ./node_modules
-COPY --from=builder /packages ./packages
-COPY --from=builder /package*.json ./
-COPY /.actor ./.actor
-COPY /main.js ./
-
-RUN echo "Installed NPM packages:" \
+ && npm update --no-audit \
+ && echo "Installed NPM packages:" \
&& (npm list --only=prod --no-optional --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
+
+COPY --chown=myuser . ./
diff --git a/test/e2e/camoufox-cloudflare/actor/main.js b/test/e2e/camoufox-cloudflare/actor/main.js
index b0756d73c..4a55d2e8c 100644
--- a/test/e2e/camoufox-cloudflare/actor/main.js
+++ b/test/e2e/camoufox-cloudflare/actor/main.js
@@ -14,6 +14,30 @@ const mainOptions = {
await Actor.main(async () => {
const crawler = new PlaywrightCrawler({
proxyConfiguration: await Actor.createProxyConfiguration(),
+ // Camoufox ships its own anti-detection; Crawlee's fingerprint injection conflicts with it
+ // and keeps Cloudflare from ever clearing the challenge.
+ browserPoolOptions: { useFingerprints: false },
+ preNavigationHooks: [
+ async ({ page }) => {
+ // TODO: remove this hook once a Camoufox build with daijro/camoufox#625 is released.
+ // Cloudflare's challenge throws cross-origin `Script error.`s with no location; Camoufox's
+ // juggler currently forwards them without a `location`, and Playwright 1.60+ then crashes
+ // the driver on `pageError.location.url` (Playwright won't guard it — microsoft/playwright#40982,
+ // declined). The fix is producer-side in daijro/camoufox#625 but not yet in a released build,
+ // so until then we swallow the errors here. See daijro/camoufox#635.
+ await page.addInitScript(() => {
+ window.addEventListener(
+ 'error',
+ (e) => {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ },
+ true,
+ );
+ window.addEventListener('unhandledrejection', (e) => e.preventDefault(), true);
+ });
+ },
+ ],
postNavigationHooks: [
async ({ handleCloudflareChallenge }) => {
await handleCloudflareChallenge();
diff --git a/test/e2e/camoufox-cloudflare/test.mjs b/test/e2e/camoufox-cloudflare/test.mjs
index 635f6fe27..e58cfcbe3 100644
--- a/test/e2e/camoufox-cloudflare/test.mjs
+++ b/test/e2e/camoufox-cloudflare/test.mjs
@@ -1,7 +1,11 @@
import { initialize, getActorTestDir, runActor, expect, skipTest } from '../tools.mjs';
-if (process.env.STORAGE_IMPLEMENTATION === 'PLATFORM') {
- await skipTest('TODO fails to build the docker image now');
+// TODO: re-enable on LOCAL/MEMORY once Camoufox supports the repo's Playwright version.
+// Those storage types import the actor in-process against the repo-root node_modules (currently
+// Playwright 1.61), but camoufox-js 0.11 ships Firefox 150 and only launches under Playwright 1.60.
+// Only the PLATFORM build isolates the actor's pinned 1.60, so the test runs there exclusively.
+if (process.env.STORAGE_IMPLEMENTATION !== 'PLATFORM') {
+ await skipTest('Camoufox needs Playwright 1.60; only the PLATFORM build can isolate it from the repo-root 1.61');
}
const testActorDirname = getActorTestDir(import.meta.url);