From 0d52600c383659d3bf6597d680e508373919bf6d Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Mon, 15 Jun 2026 12:23:22 +0300 Subject: [PATCH] feat(node)!: stop preinstalling apify, crawlee and typescript Remove apify, crawlee and typescript (and the crawlee overrides) from every node image's package.json, keeping only the browser library each image is built around (playwright/-chromium/-firefox/-webkit, puppeteer, or camoufox-js + playwright + impit for camoufox). Actors get exactly the dependency versions in their own package.json instead of whatever the image preinstalled, at the cost of installing them at build time. The default main.js smoke tests no longer depend on apify or crawlee: apify is imported optionally (falling back to running the test directly), and the browsers are driven with raw playwright/puppeteer instead of crawlee's launchers. BREAKING CHANGE: images no longer ship node_modules with apify/crawlee/ typescript. Actor templates that run `npm ls @crawlee/core apify ...` as a sanity check will fail on these images and need updating. --- node-playwright-camoufox/firefox_test.js | 24 ++++----- node-playwright-camoufox/main.js | 36 ++++++++----- node-playwright-camoufox/package.json | 12 +---- node-playwright-chrome/chrome_test.js | 20 +++---- node-playwright-chrome/main.js | 42 ++++++++------- node-playwright-chrome/package.json | 12 +---- node-playwright-firefox/firefox_test.js | 22 ++++---- node-playwright-firefox/main.js | 36 ++++++++----- node-playwright-firefox/package.json | 12 +---- node-playwright-webkit/main.js | 36 ++++++++----- node-playwright-webkit/package.json | 12 +---- node-playwright-webkit/webkit_test.js | 22 ++++---- node-playwright/chrome_test.js | 19 +++---- node-playwright/main.js | 52 ++++++++++++------- node-playwright/package.json | 12 +---- node-puppeteer-chrome/main.js | 51 +++++++++++------- node-puppeteer-chrome/package.json | 12 +---- .../puppeteer_chrome_test.js | 14 ++--- node/main.js | 26 +++++++--- node/package.json | 13 +---- 20 files changed, 239 insertions(+), 246 deletions(-) diff --git a/node-playwright-camoufox/firefox_test.js b/node-playwright-camoufox/firefox_test.js index aced688a..d692422e 100644 --- a/node-playwright-camoufox/firefox_test.js +++ b/node-playwright-camoufox/firefox_test.js @@ -1,4 +1,4 @@ -const { launchPlaywright } = require('crawlee'); +const playwright = require('playwright'); const { launchOptions: camoufoxLaunchOptions } = require('camoufox-js'); const testPageLoading = async (browser) => { @@ -6,24 +6,22 @@ const testPageLoading = async (browser) => { await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Playwright+Firefox test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Playwright+Firefox test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; -const testFirefox = async (launchOptions) => { - const launchContext = { - launcher: require('playwright').firefox, - launchOptions: await camoufoxLaunchOptions({ - ...launchOptions, - }), - }; +const testFirefox = async (launchOptions = {}) => { + const options = await camoufoxLaunchOptions({ ...launchOptions }); - console.log(`Testing Playwright with Firefox`, launchContext.launchOptions); + console.log('Testing Playwright with Camoufox', options); - const browser = await launchPlaywright(launchContext); + const browser = await playwright.firefox.launch(options); - await testPageLoading(browser); - await browser.close(); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } }; module.exports = testFirefox; diff --git a/node-playwright-camoufox/main.js b/node-playwright-camoufox/main.js index c72d1035..b3a92d0a 100644 --- a/node-playwright-camoufox/main.js +++ b/node-playwright-camoufox/main.js @@ -11,23 +11,31 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { getMemoryInfo } = require('crawlee'); -const testFirefox = require('./firefox_test'); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} -Actor.main(async () => { - // Sanity test browsers. +const testFirefox = require('./firefox_test'); - // Try to use full Firefox headless +const run = async () => { + // Camoufox (Firefox) headless await testFirefox({ headless: true }); - // Try to use full Firefox with XVFB + // Camoufox (Firefox) with XVFB (headful) await testFirefox({ headless: false }); - // Try to use playwright default - await testFirefox({ executablePath: undefined }); - await testFirefox({ executablePath: process.env.APIFY_DEFAULT_BROWSER_PATH }); - - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); -}); + console.log('... test PASSED'); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-playwright-camoufox/package.json b/node-playwright-camoufox/package.json index e3d603c6..680a3381 100644 --- a/node-playwright-camoufox/package.json +++ b/node-playwright-camoufox/package.json @@ -7,19 +7,9 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", "camoufox-js": "CAMOUFOX_VERSION", - "crawlee": "CRAWLEE_VERSION", "impit": "latest", - "playwright": "PLAYWRIGHT_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "playwright": "PLAYWRIGHT_VERSION" }, "repository": {} } diff --git a/node-playwright-chrome/chrome_test.js b/node-playwright-chrome/chrome_test.js index 746a576f..8b04e139 100644 --- a/node-playwright-chrome/chrome_test.js +++ b/node-playwright-chrome/chrome_test.js @@ -1,25 +1,27 @@ -const { launchPlaywright } = require('crawlee'); +const playwright = require('playwright'); const testPageLoading = async (browser) => { const page = await browser.newPage(); await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Playwright+Chrome test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Playwright+Chrome test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; -const testChrome = async (launchOptions) => { - const launchContext = { useChrome: true, launchOptions }; +const testChrome = async (launchOptions = {}) => { + console.log('Testing Playwright with Chrome', launchOptions); - console.log(`Testing Playwright with Chrome`, launchContext); + const browser = await playwright.chromium.launch({ channel: 'chrome', ...launchOptions }); - const browser = await launchPlaywright(launchContext); - - await testPageLoading(browser); - await browser.close(); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } }; module.exports = { testChrome, + testPageLoading, }; diff --git a/node-playwright-chrome/main.js b/node-playwright-chrome/main.js index b7354da0..897983d0 100644 --- a/node-playwright-chrome/main.js +++ b/node-playwright-chrome/main.js @@ -11,29 +11,31 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { launchPlaywright, getMemoryInfo } = require('crawlee'); -const { testChrome } = require('./chrome_test'); - -Actor.main(async () => { - // Sanity test browsers. - // We need --no-sandbox, because even though the build is running on GitHub, the test is running in Docker. - const launchOptions = { headless: true, args: ['--no-sandbox'] }; - const launchContext = { launchOptions }; +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} - const browser = await launchPlaywright(launchContext); - await browser.close(); +const { testChrome } = require('./chrome_test'); - // Try to use full Chrome headless +const run = async () => { + // Full Chrome headless await testChrome({ headless: true }); - // Try to use full Chrome with XVFB + // Full Chrome with XVFB (headful) await testChrome({ headless: false }); - // Try to use playwright default - await testChrome({ executablePath: undefined }); - await testChrome({ executablePath: process.env.APIFY_DEFAULT_BROWSER_PATH }); - - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); -}); + console.log('... test PASSED'); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-playwright-chrome/package.json b/node-playwright-chrome/package.json index 9d10b6fd..3ae50f8d 100644 --- a/node-playwright-chrome/package.json +++ b/node-playwright-chrome/package.json @@ -7,17 +7,7 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "playwright-chromium": "PLAYWRIGHT_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "playwright-chromium": "PLAYWRIGHT_VERSION" }, "repository": {} } diff --git a/node-playwright-firefox/firefox_test.js b/node-playwright-firefox/firefox_test.js index 29c8b4aa..c16240f7 100644 --- a/node-playwright-firefox/firefox_test.js +++ b/node-playwright-firefox/firefox_test.js @@ -1,26 +1,24 @@ -const { launchPlaywright } = require('crawlee'); +const playwright = require('playwright'); const testPageLoading = async (browser) => { const page = await browser.newPage(); await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Playwright+Firefox test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Playwright+Firefox test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; -const testFirefox = async (launchOptions) => { - const launchContext = { - launcher: require('playwright').firefox, - launchOptions, - }; +const testFirefox = async (launchOptions = {}) => { + console.log('Testing Playwright with Firefox', launchOptions); - console.log(`Testing Playwright with Firefox`, launchOptions); + const browser = await playwright.firefox.launch(launchOptions); - const browser = await launchPlaywright(launchContext); - - await testPageLoading(browser); - await browser.close(); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } }; module.exports = testFirefox; diff --git a/node-playwright-firefox/main.js b/node-playwright-firefox/main.js index c72d1035..5cf22bcf 100644 --- a/node-playwright-firefox/main.js +++ b/node-playwright-firefox/main.js @@ -11,23 +11,31 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { getMemoryInfo } = require('crawlee'); -const testFirefox = require('./firefox_test'); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} -Actor.main(async () => { - // Sanity test browsers. +const testFirefox = require('./firefox_test'); - // Try to use full Firefox headless +const run = async () => { + // Full Firefox headless await testFirefox({ headless: true }); - // Try to use full Firefox with XVFB + // Full Firefox with XVFB (headful) await testFirefox({ headless: false }); - // Try to use playwright default - await testFirefox({ executablePath: undefined }); - await testFirefox({ executablePath: process.env.APIFY_DEFAULT_BROWSER_PATH }); - - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); -}); + console.log('... test PASSED'); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-playwright-firefox/package.json b/node-playwright-firefox/package.json index 49e046e5..4644a5e3 100644 --- a/node-playwright-firefox/package.json +++ b/node-playwright-firefox/package.json @@ -7,17 +7,7 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "playwright-firefox": "PLAYWRIGHT_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "playwright-firefox": "PLAYWRIGHT_VERSION" }, "repository": {} } diff --git a/node-playwright-webkit/main.js b/node-playwright-webkit/main.js index 864bbecc..c523a247 100644 --- a/node-playwright-webkit/main.js +++ b/node-playwright-webkit/main.js @@ -11,23 +11,31 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { getMemoryInfo } = require('crawlee'); -const testWebkit = require('./webkit_test'); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} -Actor.main(async () => { - // Sanity test browsers. +const testWebkit = require('./webkit_test'); - // Try to use full Webkit headless +const run = async () => { + // Full Webkit headless await testWebkit({ headless: true }); - // Try to use full Webkit with XVFB + // Full Webkit with XVFB (headful) await testWebkit({ headless: false }); - // Try to use playwright default - await testWebkit({ executablePath: undefined }); - await testWebkit({ executablePath: process.env.APIFY_DEFAULT_BROWSER_PATH }); - - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); -}); + console.log('... test PASSED'); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-playwright-webkit/package.json b/node-playwright-webkit/package.json index 1e457900..06d09a99 100644 --- a/node-playwright-webkit/package.json +++ b/node-playwright-webkit/package.json @@ -7,17 +7,7 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "playwright-webkit": "PLAYWRIGHT_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "playwright-webkit": "PLAYWRIGHT_VERSION" }, "repository": {} } diff --git a/node-playwright-webkit/webkit_test.js b/node-playwright-webkit/webkit_test.js index 48db32e0..03f10992 100644 --- a/node-playwright-webkit/webkit_test.js +++ b/node-playwright-webkit/webkit_test.js @@ -1,26 +1,24 @@ -const { launchPlaywright } = require('crawlee'); +const playwright = require('playwright'); const testPageLoading = async (browser) => { const page = await browser.newPage(); await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Playwright+Webkit test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Playwright+Webkit test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; -const testWebkit = async (launchOptions) => { - const launchContext = { - launcher: require('playwright').webkit, - launchOptions, - }; +const testWebkit = async (launchOptions = {}) => { + console.log('Testing Playwright with Webkit', launchOptions); - console.log(`Testing Playwright with Webkit`, launchOptions); + const browser = await playwright.webkit.launch(launchOptions); - const browser = await launchPlaywright(launchContext); - - await testPageLoading(browser); - await browser.close(); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } }; module.exports = testWebkit; diff --git a/node-playwright/chrome_test.js b/node-playwright/chrome_test.js index d07ff037..8b04e139 100644 --- a/node-playwright/chrome_test.js +++ b/node-playwright/chrome_test.js @@ -1,23 +1,24 @@ -const { launchPlaywright } = require('crawlee'); +const playwright = require('playwright'); const testPageLoading = async (browser) => { const page = await browser.newPage(); await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Playwright+Chrome test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Playwright+Chrome test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; -const testChrome = async (launchOptions) => { - const launchContext = { useChrome: true, launchOptions }; +const testChrome = async (launchOptions = {}) => { + console.log('Testing Playwright with Chrome', launchOptions); - console.log(`Testing Playwright with Chrome`, launchContext); + const browser = await playwright.chromium.launch({ channel: 'chrome', ...launchOptions }); - const browser = await launchPlaywright(launchContext); - - await testPageLoading(browser); - await browser.close(); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } }; module.exports = { diff --git a/node-playwright/main.js b/node-playwright/main.js index 04966c17..a3840811 100644 --- a/node-playwright/main.js +++ b/node-playwright/main.js @@ -11,27 +11,33 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { launchPlaywright, getMemoryInfo } = require('crawlee'); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} + const playwright = require('playwright'); const { testChrome, testPageLoading } = require('./chrome_test'); -Actor.main(async () => { +const run = async () => { const browsers = ['webkit', 'firefox', 'chromium']; - const promisesHeadless = browsers.map(async (browserName) => { - console.log(`Testing Playwright with ${browserName} and headless`); - const browser = await launchPlaywright({ launcher: playwright[browserName] }); - return testPageLoading(browser); - }); - - const promisesHeadful = browsers.map(async (browserName) => { - console.log(`Testing Playwright with ${browserName} and headful`); - const browser = await launchPlaywright({ launcher: playwright[browserName], launchOptions: { headless: false } }); - return testPageLoading(browser); - }); - await Promise.all(promisesHeadless); - await Promise.all(promisesHeadful); + for (const headless of [true, false]) { + await Promise.all( + browsers.map(async (browserName) => { + console.log(`Testing Playwright with ${browserName} and ${headless ? 'headless' : 'headful'}`); + const browser = await playwright[browserName].launch({ headless }); + try { + await testPageLoading(browser); + } finally { + await browser.close(); + } + }), + ); + } // Try to use full Chrome headless await testChrome({ headless: true }); @@ -39,8 +45,14 @@ Actor.main(async () => { // Try to use full Chrome with XVFB await testChrome({ headless: false, args: ['--disable-gpu'] }); - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); - console.log('All tests passed!'); -}); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-playwright/package.json b/node-playwright/package.json index 76ef31f6..8a4fe092 100644 --- a/node-playwright/package.json +++ b/node-playwright/package.json @@ -7,17 +7,7 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "playwright": "PLAYWRIGHT_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "playwright": "PLAYWRIGHT_VERSION" }, "repository": {} } diff --git a/node-puppeteer-chrome/main.js b/node-puppeteer-chrome/main.js index e9eab3e9..1338b73a 100644 --- a/node-puppeteer-chrome/main.js +++ b/node-puppeteer-chrome/main.js @@ -11,29 +11,44 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { launchPuppeteer, getMemoryInfo } = require('crawlee'); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} + +const puppeteer = require('puppeteer'); const testPuppeteerChrome = require('./puppeteer_chrome_test'); -Actor.main(async () => { - // First, try to open Chromium to see all dependencies are correctly installed +const run = async () => { + // First, open the Chromium bundled with Puppeteer to verify dependencies are installed. console.log('Testing Puppeteer with Chromium'); - // We need --no-sandbox, because even though the build is running on GitHub, the test is running in Docker. - const launchOptions = { headless: true, args: ['--no-sandbox'] }; - const browser1 = await launchPuppeteer({ launchOptions }); - const page1 = await browser1.newPage(); - await page1.goto('http://www.example.com'); - const pageTitle1 = await page1.title(); - if (pageTitle1 !== 'Example Domain') { - throw new Error(`Puppeteer+Chromium test failed - returned title "${pageTitle1}"" !== "Example Domain"`); + // We need --no-sandbox, because even though the build runs on GitHub, the test runs in Docker. + const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] }); + try { + const page = await browser.newPage(); + await page.goto('http://www.example.com'); + const pageTitle = await page.title(); + if (pageTitle !== 'Example Domain') { + throw new Error(`Puppeteer+Chromium test failed - returned title "${pageTitle}" !== "Example Domain"`); + } + } finally { + await browser.close(); } - await browser1.close(); - // Second, try to use full Chrome + // Second, use full Chrome. await testPuppeteerChrome(); - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); - console.log('... test PASSED'); -}); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node-puppeteer-chrome/package.json b/node-puppeteer-chrome/package.json index be665a85..6d9aaf45 100644 --- a/node-puppeteer-chrome/package.json +++ b/node-puppeteer-chrome/package.json @@ -7,17 +7,7 @@ "start": "node main.js" }, "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "puppeteer": "PUPPETEER_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } + "puppeteer": "PUPPETEER_VERSION" }, "repository": {} } diff --git a/node-puppeteer-chrome/puppeteer_chrome_test.js b/node-puppeteer-chrome/puppeteer_chrome_test.js index 55122a18..38a5a473 100644 --- a/node-puppeteer-chrome/puppeteer_chrome_test.js +++ b/node-puppeteer-chrome/puppeteer_chrome_test.js @@ -1,21 +1,23 @@ -const { launchPuppeteer } = require('crawlee'); +const puppeteer = require('puppeteer'); const testPageLoading = async (browser) => { const page = await browser.newPage(); await page.goto('http://www.example.com'); const pageTitle = await page.title(); if (pageTitle !== 'Example Domain') { - throw new Error(`Puppeteer+Chrome test failed - returned title "${pageTitle}"" !== "Example Domain"`); + throw new Error(`Puppeteer+Chrome test failed - returned title "${pageTitle}" !== "Example Domain"`); } }; const testPuppeteerChrome = async () => { console.log('Testing Puppeteer with full Chrome'); - // We need --no-sandbox, because even though the build is running on GitHub, the test is running in Docker. - const launchOptions = { headless: true, args: ['--no-sandbox'] }; - const launchContext = { useChrome: true, launchOptions }; + // We need --no-sandbox, because even though the build runs on GitHub, the test runs in Docker. + const browser = await puppeteer.launch({ + headless: true, + args: ['--no-sandbox'], + executablePath: process.env.APIFY_CHROME_EXECUTABLE_PATH, + }); - const browser = await launchPuppeteer(launchContext); try { await testPageLoading(browser); } finally { diff --git a/node/main.js b/node/main.js index bf328376..335c506f 100644 --- a/node/main.js +++ b/node/main.js @@ -11,12 +11,24 @@ For more information, see https://docs.apify.com/actors/development/source-code# `); console.log('Testing Docker image...'); -const { Actor } = require('apify'); -const { getMemoryInfo } = require('crawlee'); - -Actor.main(async () => { - // Test that "ps" command is available, sometimes it was missing in official Node builds - await getMemoryInfo(); +// `apify` is optional: the image no longer preinstalls it. +let Actor; +try { + ({ Actor } = require('apify')); +} catch { + Actor = undefined; +} +const run = async () => { + // The base Node image has no browser to exercise; just confirm the runtime starts. console.log('... test PASSED'); -}); +}; + +if (Actor) { + Actor.main(run); +} else { + run().catch((error) => { + console.error(error); + process.exitCode = 1; + }); +} diff --git a/node/package.json b/node/package.json index 1a942f8e..17738656 100644 --- a/node/package.json +++ b/node/package.json @@ -6,17 +6,6 @@ "scripts": { "start": "node main.js" }, - "dependencies": { - "apify": "APIFY_VERSION", - "crawlee": "CRAWLEE_VERSION", - "typescript": "^5.4.3" - }, - "overrides": { - "apify": { - "@crawlee/core": "CRAWLEE_VERSION", - "@crawlee/types": "CRAWLEE_VERSION", - "@crawlee/utils": "CRAWLEE_VERSION" - } - }, + "dependencies": {}, "repository": {} }