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.

Add implementation

Ondra Urban2270f77f421b
diff --git a/src/basic_crawler.js b/src/basic_crawler.js
index 7618c80eb..cf978e29d 100644
--- a/src/basic_crawler.js
+++ b/src/basic_crawler.js
@@ -7,6 +7,7 @@ import AutoscaledPool from './autoscaling/autoscaled_pool';
import { RequestList } from './request_list';
import { RequestQueue, RequestQueueLocal } from './request_queue';
import events from './events';
+import { addTimeoutToPromise } from './utils';
/**
* Since there's no set number of seconds before the container is terminated after
@@ -23,6 +24,7 @@ const SAFE_MIGRATION_WAIT_MILLIS = 20000;
const DEFAULT_OPTIONS = {
maxRequestRetries: 3,
+ handleRequestTimeoutSecs: 60,
handleFailedRequestFunction: ({ request }) => {
const details = _.pick(request, 'id', 'url', 'method', 'uniqueKey');
log.error('BasicCrawler: Request failed and reached maximum retries', details);
@@ -112,6 +114,8 @@ const DEFAULT_OPTIONS = {
* @param {RequestQueue} options.requestQueue
* Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
* Either `requestList` or `requestQueue` option must be provided (or both).
+ * @param {number} [options.handleRequestTimeoutSecs=60]
+ * Timeout in which the function passed as `options.handleRequestFunction` needs to finish, in seconds.
* @param {Function} [options.handleFailedRequestFunction]
* A function to handle requests that failed more than `option.maxRequestRetries` times.
*
@@ -152,6 +156,7 @@ class BasicCrawler {
requestList,
requestQueue,
handleRequestFunction,
+ handleRequestTimeoutSecs,
handleFailedRequestFunction,
maxRequestRetries,
maxRequestsPerCrawl,
@@ -165,6 +170,7 @@ class BasicCrawler {
checkParamPrototypeOrThrow(requestList, 'options.requestList', RequestList, 'Apify.RequestList', true);
checkParamPrototypeOrThrow(requestQueue, 'options.requestQueue', [RequestQueue, RequestQueueLocal], 'Apify.RequestQueue', true);
checkParamOrThrow(handleRequestFunction, 'options.handleRequestFunction', 'Function');
+ checkParamOrThrow(handleRequestTimeoutSecs, 'options.handleRequestTimeoutSecs', 'Number');
checkParamOrThrow(handleFailedRequestFunction, 'options.handleFailedRequestFunction', 'Function');
checkParamOrThrow(maxRequestRetries, 'options.maxRequestRetries', 'Number');
checkParamOrThrow(maxRequestsPerCrawl, 'options.maxRequestsPerCrawl', 'Maybe Number');
@@ -177,6 +183,7 @@ class BasicCrawler {
this.requestList = requestList;
this.requestQueue = requestQueue;
this.handleRequestFunction = handleRequestFunction;
+ this.handleRequestTimeoutMillis = handleRequestTimeoutSecs * 1000;
this.handleFailedRequestFunction = handleFailedRequestFunction;
this.maxRequestRetries = maxRequestRetries;
this.handledRequestsCount = 0;
@@ -317,19 +324,19 @@ class BasicCrawler {
request.loadedUrl = null;
try {
- await this.handleRequestFunction({ request, autoscaledPool: this.autoscaledPool });
+ await addTimeoutToPromise(
+ this.handleRequestFunction({ request, autoscaledPool: this.autoscaledPool }),
+ this.handleRequestTimeoutMillis,
+ 'BasicCrawler: handleRequestFunction timed out.',
+ );
await source.markRequestHandled(request);
this.handledRequestsCount++;
} catch (err) {
try {
- // TODO Errors thrown from within the error handler will in most cases terminate
- // the crawler because runTaskFunction errors kill autoscaled pool
- // which is correct, since in this case, RequestQueue is probably in an unknown
- // state.
await this._requestFunctionErrorHandler(err, request, source);
} catch (secondaryError) {
log.exception(secondaryError, 'BasicCrawler: runTaskFunction error handler threw an exception. '
- + 'This places the crawler and it\'s underlying storages into an unknown state and crawling will be terminated. '
+ + 'This places the crawler and its underlying storages into an unknown state and crawling will be terminated. '
+ 'This may have happened due to an internal error of Apify\'s API or due to a misconfigured crawler. '
+ 'If you are sure that there is no error in your code, selecting "Restart on error" in the actor\'s settings'
+ 'will make sure that the run continues where it left off, if programmed to handle restarts correctly.');
diff --git a/src/puppeteer_crawler.js b/src/puppeteer_crawler.js
index c19567344..7855ef4e7 100644
--- a/src/puppeteer_crawler.js
+++ b/src/puppeteer_crawler.js
@@ -14,8 +14,6 @@ const DEFAULT_OPTIONS = {
},
};
-const PAGE_CLOSE_TIMEOUT_MILLIS = 30000;
-
/**
* Provides a simple framework for parallel crawling of web pages
* using headless Chrome with <a href="https://github.com/GoogleChrome/puppeteer" target="_blank">Puppeteer</a>.
@@ -147,37 +145,18 @@ const PAGE_CLOSE_TIMEOUT_MILLIS = 30000;
* Maximum number of pages that the crawler will open. The crawl will stop when this limit is reached.
* Always set this value in order to prevent infinite loops in misconfigured crawlers.
* Note that in cases of parallel crawling, the actual number of pages visited might be slightly higher than this value.
- * @param {Number} [options.maxOpenPagesPerInstance=50]
- * Maximum number of opened tabs per browser. If this limit is reached then a new
- * browser instance is started. See `maxOpenPagesPerInstance` parameter of {@link PuppeteerPool}.
- * @param {Number} [options.retireInstanceAfterRequestCount=100]
- * Maximum number of requests that can be processed by a single browser instance.
- * After the limit is reached the browser will be retired and new requests will
- * be handled by a new browser instance.
- * See `retireInstanceAfterRequestCount` parameter of {@link PuppeteerPool}.
- * @param {Number} [options.instanceKillerIntervalMillis=60000]
- * Indicates how often are the open Puppeteer instances checked whether they can be closed.
- * See `instanceKillerIntervalMillis` parameter of {@link PuppeteerPool}.
- * @param {Number} [options.killInstanceAfterMillis=300000]
- * If Puppeteer instance reaches the `options.retireInstanceAfterRequestCount` limit then
- * it is considered retired and no more tabs will be opened. After the last tab is closed
- * the whole browser is closed too. This parameter defines a time limit for inactivity
- * after which the browser is closed even if there are pending tabs. See
- * `killInstanceAfterMillis` parameter of {@link PuppeteerPool}.
- * @param {String[]} [options.proxyUrls]
- * An array of custom proxy URLs to be used by the {@link PuppeteerPool} instance.
- * The provided custom proxies' order will be randomized and the resulting list rotated.
- * Custom proxies are not compatible with Apify Proxy and an attempt to use both
- * configuration options will cause an error to be thrown on startup.
+ * @param {Object} [options.puppeteerPoolOptions]
+ * Custom options passed to the underlying {@link PuppeteerPool} constructor.
+ * You can tweak those to fine-tune browser management.
* @param {Function} [options.launchPuppeteerFunction]
* Overrides the default function to launch a new Puppeteer instance.
- * See `launchPuppeteerFunction` parameter of {@link PuppeteerPool}.
+ * Shortcut to the corresponding {@link PuppeteerPool} option.
* See source code on
* <a href="https://github.com/apifytech/apify-js/blob/master/src/puppeteer_pool.js#L28" target="_blank">GitHub</a>
* for default behavior.
* @param {LaunchPuppeteerOptions} [options.launchPuppeteerOptions]
* Options used by [`Apify.launchPuppeteer()`](apify#module_Apify.launchPuppeteer) to start new Puppeteer instances.
- * See `launchPuppeteerOptions` parameter of {@link PuppeteerPool} and [`LaunchPuppeteerOptions`](../typedefs/launchpuppeteeroptions).
+ * Shortcut to the corresponding {@link PuppeteerPool} option. See [`LaunchPuppeteerOptions`](../typedefs/launchpuppeteeroptions).
* @param {Object} [options.autoscaledPoolOptions]
* Custom options passed to the underlying {@link AutoscaledPool} instance constructor.
* Note that the `runTaskFunction`, `isTaskReadyFunction` and `isFinishedFunction` options
@@ -192,16 +171,9 @@ const PAGE_CLOSE_TIMEOUT_MILLIS = 30000;
*/
class PuppeteerCrawler {
constructor(options) {
- // For backwards compatibility, in the future we can remove this...
- if (!options.retireInstanceAfterRequestCount && options.abortInstanceAfterRequestCount) {
- log.warning('PuppeteerCrawler: Parameter `abortInstanceAfterRequestCount` is deprecated! Use `retireInstanceAfterRequestCount` instead!');
- options.retireInstanceAfterRequestCount = options.abortInstanceAfterRequestCount;
- }
-
const {
handlePageFunction,
gotoFunction,
- pageOpsTimeoutMillis, // Deprecated, remove in the future.
handlePageTimeoutSecs,
// AutoscaledPool shorthands
@@ -216,38 +188,25 @@ class PuppeteerCrawler {
handleFailedRequestFunction,
autoscaledPoolOptions,
- // PuppeteerPool options
- // TODO: We should put these into a single object, similarly to autoscaledPoolOptions
- reusePages,
- maxOpenPagesPerInstance,
- retireInstanceAfterRequestCount,
- instanceKillerIntervalMillis,
- killInstanceAfterMillis,
- proxyUrls,
+ // PuppeteerPool options and shorthands
+ puppeteerPoolOptions,
launchPuppeteerFunction,
launchPuppeteerOptions,
} = _.defaults({}, options, DEFAULT_OPTIONS);
checkParamOrThrow(handlePageFunction, 'options.handlePageFunction', 'Function');
+ checkParamOrThrow(handlePageTimeoutSecs, 'options.handlePageTimeoutSecs', 'Number');
checkParamOrThrow(handleFailedRequestFunction, 'options.handleFailedRequestFunction', 'Maybe Function');
checkParamOrThrow(gotoFunction, 'options.gotoFunction', 'Function');
+ checkParamOrThrow(puppeteerPoolOptions, 'options.puppeteerPoolOptions', 'Maybe Object');
this.handlePageFunction = handlePageFunction;
this.gotoFunction = gotoFunction;
- if (pageOpsTimeoutMillis) log.warning('options.pageOpsTimeoutMillis is deprecated, use options.handlePageTimeoutSecs instead.');
- this.handlePageTimeoutMillis = handlePageTimeoutSecs * 1000 || pageOpsTimeoutMillis;
+ this.handlePageTimeoutMillis = handlePageTimeoutSecs * 1000;
- this.puppeteerPoolOptions = {
- reusePages,
- maxOpenPagesPerInstance,
- retireInstanceAfterRequestCount,
- instanceKillerIntervalMillis,
- killInstanceAfterMillis,
- proxyUrls,
- launchPuppeteerFunction,
- launchPuppeteerOptions,
- };
+ // puppeteerPoolOptions can be null or undefined or Object, so we merge it this way, because null is not replaced by defaults above.
+ this.puppeteerPoolOptions = Object.assign({}, puppeteerPoolOptions, { launchPuppeteerFunction, launchPuppeteerOptions });
this.puppeteerPool = null; // Constructed when .run()
@@ -258,6 +217,7 @@ class PuppeteerCrawler {
maxRequestRetries,
maxRequestsPerCrawl,
handleRequestFunction: (...args) => this._handleRequestFunction(...args),
+ handleRequestTimeoutSecs: handlePageTimeoutSecs * 2,
handleFailedRequestFunction,
// Autoscaled pool options.
@@ -300,15 +260,7 @@ class PuppeteerCrawler {
'PuppeteerCrawler: handlePageFunction timed out.',
);
} finally {
- try {
- await addTimeoutToPromise(
- this.puppeteerPool.recyclePage(page),
- PAGE_CLOSE_TIMEOUT_MILLIS,
- 'Operation timed out.',
- );
- } catch (err) {
- log.debug('PuppeteerCrawler: Page.close() failed.', { reason: err && err.message });
- }
+ await this.puppeteerPool.recyclePage(page);
}
}
}
diff --git a/src/puppeteer_pool.js b/src/puppeteer_pool.js
index 3188f01f8..ec1d93086 100644
--- a/src/puppeteer_pool.js
+++ b/src/puppeteer_pool.js
@@ -8,11 +8,11 @@ import LinkedList from 'apify-shared/linked_list';
import rimraf from 'rimraf';
import { checkParamOrThrow } from 'apify-client/build/utils';
import { launchPuppeteer } from './puppeteer';
+import { addTimeoutToPromise } from './utils';
/* global process */
const PROCESS_KILL_TIMEOUT_MILLIS = 5000;
-const PAGE_CLOSE_KILL_TIMEOUT_MILLIS = 1000;
const DEFAULT_OPTIONS = {
reusePages: false,
@@ -21,9 +21,9 @@ const DEFAULT_OPTIONS = {
maxOpenPagesPerInstance: 50,
retireInstanceAfterRequestCount: 100,
- // These can't be constants because we need it for unit tests.
- instanceKillerIntervalMillis: 60 * 1000,
- killInstanceAfterMillis: 5 * 60 * 1000,
+ puppeteerOperationTimeoutSecs: 15,
+ instanceKillerIntervalSecs: 60,
+ killInstanceAfterSecs: 300,
// TODO: use settingsRotator()
launchPuppeteerFunction: launchPuppeteerOptions => launchPuppeteer(launchPuppeteerOptions),
@@ -109,9 +109,13 @@ class PuppeteerInstance {
* Maximum number of requests that can be processed by a single browser instance.
* After the limit is reached, the browser is retired and new requests are
* handled by a new browser instance.
- * @param {Number} [options.instanceKillerIntervalMillis=60000]
+ * @param {Number} [options.puppeteerOperationTimeoutSecs=15]
+ * All browser management operations such as launching a new browser, opening a new page
+ * or closing a page will timeout after the set number of seconds and the connected
+ * browser will be retired.
+ * @param {Number} [options.instanceKillerIntervalSecs=60]
* Indicates how often are the open Puppeteer instances checked whether they can be closed.
- * @param {Number} [options.killInstanceAfterMillis=300000]
+ * @param {Number} [options.killInstanceAfterSecs=300]
* When Puppeteer instance reaches the `options.retireInstanceAfterRequestCount` limit then
* it is considered retired and no more tabs will be opened. After the last tab is closed the
* whole browser is closed too. This parameter defines a time limit between the last tab was opened and
@@ -134,20 +138,15 @@ class PuppeteerInstance {
*/
class PuppeteerPool {
constructor(options = {}) {
- checkParamOrThrow(options, 'options', 'Object');
-
- // For backwards compatibility, in the future we can remove this...
- if (!options.retireInstanceAfterRequestCount && options.abortInstanceAfterRequestCount) {
- log.warning('PuppeteerPool: Parameter `abortInstanceAfterRequestCount` is deprecated! Use `retireInstanceAfterRequestCount` instead!');
- options.retireInstanceAfterRequestCount = options.abortInstanceAfterRequestCount;
- }
-
const {
maxOpenPagesPerInstance,
retireInstanceAfterRequestCount,
launchPuppeteerFunction,
+ puppeteerOperationTimeoutSecs,
instanceKillerIntervalMillis,
+ instanceKillerIntervalSecs,
killInstanceAfterMillis,
+ killInstanceAfterSecs,
launchPuppeteerOptions,
// recycleDiskCache,
proxyUrls,
@@ -163,8 +162,17 @@ class PuppeteerPool {
checkParamOrThrow(maxOpenPagesPerInstance, 'options.maxOpenPagesPerInstance', 'Number');
checkParamOrThrow(retireInstanceAfterRequestCount, 'options.retireInstanceAfterRequestCount', 'Number');
checkParamOrThrow(launchPuppeteerFunction, 'options.launchPuppeteerFunction', 'Function');
- checkParamOrThrow(instanceKillerIntervalMillis, 'options.instanceKillerIntervalMillis', 'Number');
- checkParamOrThrow(killInstanceAfterMillis, 'options.killInstanceAfterMillis', 'Number');
+ checkParamOrThrow(puppeteerOperationTimeoutSecs, 'options.puppeteerOperationTimeoutSecs', 'Number');
+ checkParamOrThrow(instanceKillerIntervalMillis, 'options.instanceKillerIntervalMillis', 'Maybe Number');
+ if (instanceKillerIntervalMillis) {
+ log.deprecated('PuppeteerPool: options.instanceKillerIntervalMillis is deprecated, use options.instanceKillerIntervalSecs instead.');
+ }
+ checkParamOrThrow(instanceKillerIntervalSecs, 'options.instanceKillerIntervalSecs', 'Number');
+ checkParamOrThrow(killInstanceAfterMillis, 'options.killInstanceAfterMillis', 'Maybe Number');
+ if (killInstanceAfterMillis) {
+ log.deprecated('PuppeteerPool: options.killInstanceAfterMillis is deprecated, use options.killInstanceAfterSecs instead.');
+ }
+ checkParamOrThrow(killInstanceAfterSecs, 'options.killInstanceAfterSecs', 'Number');
checkParamOrThrow(launchPuppeteerOptions, 'options.launchPuppeteerOptions', 'Maybe Object');
checkParamOrThrow(recycleDiskCache, 'options.recycleDiskCache', 'Maybe Boolean');
checkParamOrThrow(proxyUrls, 'options.proxyUrls', 'Maybe Array');
@@ -184,7 +192,8 @@ class PuppeteerPool {
this.reusePages = reusePages;
this.maxOpenPagesPerInstance = maxOpenPagesPerInstance;
this.retireInstanceAfterRequestCount = retireInstanceAfterRequestCount;
- this.killInstanceAfterMillis = killInstanceAfterMillis;
+ this.puppeteerOperationTimeoutMillis = puppeteerOperationTimeoutSecs * 1000;
+ this.killInstanceAfterMillis = killInstanceAfterMillis || killInstanceAfterSecs * 1000;
this.recycledDiskCacheDirs = recycleDiskCache ? new LinkedList() : null;
this.proxyUrls = proxyUrls ? _.shuffle(proxyUrls) : null;
this.launchPuppeteerFunction = async () => {
@@ -220,7 +229,10 @@ class PuppeteerPool {
this.activeInstances = {};
this.retiredInstances = {};
this.lastUsedProxyUrlIndex = 0;
- this.instanceKillerInterval = setInterval(() => this._killRetiredInstances(), instanceKillerIntervalMillis);
+ this.instanceKillerInterval = setInterval(
+ () => this._killRetiredInstances(),
+ instanceKillerIntervalMillis || instanceKillerIntervalSecs * 1000,
+ );
this.idlePages = [];
// WeakSet/Map items do not prevent garbage collection,
// and thus no management of the collections is needed.
@@ -243,7 +255,11 @@ class PuppeteerPool {
const id = this.browserCounter++;
log.debug('PuppeteerPool: Launching new browser', { id });
- const browserPromise = this.launchPuppeteerFunction();
+ const browserPromise = addTimeoutToPromise(
+ this.launchPuppeteerFunction(),
+ this.puppeteerOperationTimeoutMillis,
+ 'PuppeteerPool: launchPuppeteerFunction timed out.',
+ );
const instance = new PuppeteerInstance(id, browserPromise);
this.activeInstances[id] = instance;
@@ -289,14 +305,8 @@ class PuppeteerPool {
instance.activePages--;
if (instance.activePages === 0 && this.retiredInstances[id]) {
- // Run this with a delay, otherwise page.close() that initiated this 'targetdestroyed' event
- // might fail with "Protocol error (Target.closeTarget): Target closed."
- // TODO: Alternatively we could close here the first about:blank tab, which will cause
- // the browser to be closed immediately without waiting
- setTimeout(() => {
- log.debug('PuppeteerPool: Killing retired browser because it has no active pages', { id });
- this._killInstance(instance);
- }, PAGE_CLOSE_KILL_TIMEOUT_MILLIS);
+ log.debug('PuppeteerPool: Killing retired browser because it has no active pages', { id });
+ this._killInstance(instance);
}
});
}
@@ -383,10 +393,11 @@ class PuppeteerPool {
try {
const browser = await browserPromise;
instance.killed = true;
- await browser.close();
+ // Close the about:blank page to close the browser.
+ await (await browser.pages())[0].close();
recycleDiskCache();
} catch (err) {
- log.exception(err, 'PuppeteerPool: Cannot close the browser instance', { id });
+ log.exception(err, 'PuppeteerPool: Cannot close the browser instance, it will be killed forcibly.', { id });
}
}
@@ -399,7 +410,7 @@ class PuppeteerPool {
const allInstances = Object.values(this.activeInstances).concat(Object.values(this.retiredInstances));
allInstances.forEach((instance) => {
try {
- instance.childProcess.kill('SIGINT');
+ instance.childProcess.kill('SIGKILL');
} catch (e) {
// do nothing, it's dead
}
@@ -449,7 +460,7 @@ class PuppeteerPool {
}
}
// If there are no live pages to be reused, we spawn a new tab.
- return this._openNewTab();
+ return this._openNewTab(2);
}
/**
@@ -457,10 +468,11 @@ class PuppeteerPool {
* that resolves to an instance of a Puppeteer
* <a href="https://pptr.dev/#?product=Puppeteer&show=api-class-page" target="_blank"><code>Page</code></a>.
*
+ * @param {number} retryCount
* @return {Promise<Page>}
* @ignore
*/
- async _openNewTab() {
+ async _openNewTab(retryCount) {
let instance = Object
.values(this.activeInstances)
.find(inst => inst.activePages < this.maxOpenPagesPerInstance);
@@ -471,16 +483,28 @@ class PuppeteerPool {
try {
const browser = await instance.browserPromise;
- const page = await browser.newPage();
+ const page = await addTimeoutToPromise(
+ browser.newPage(),
+ this.puppeteerOperationTimeoutMillis,
+ 'PuppeteerPool: browser.newPage() timed out.',
+ );
this._focusOldestTab(browser).catch(() => log.debug('Could not focus oldest tab.'));
this.pagesToInstancesMap.set(page, instance);
return this._decoratePage(page);
} catch (err) {
- log.exception(err, 'PuppeteerPool: Browser.newPage() failed', { id: instance.id });
this._retireInstance(instance);
-
- // !TODO: don't throw an error but repeat newPage with some delay
- throw err;
+ if (retryCount) {
+ return new Promise((resolve) => {
+ // We can do this because _retireInstance is synchronous
+ // so the page will open in a different browser.
+ setImmediate(() => {
+ resolve(this._openNewTab(--retryCount));
+ });
+ });
+ }
+ const betterError = new Error(`PuppeteerPool: browser.newPage() failed: ${instance.id}.`);
+ betterError.stack = err.stack;
+ throw betterError;
}
}
@@ -614,7 +638,15 @@ class PuppeteerPool {
page.removeAllListeners();
this.idlePages.push(page);
} else {
- await page.close();
+ try {
+ await addTimeoutToPromise(
+ page.close(),
+ this.puppeteerOperationTimeoutMillis,
+ 'PuppeteerPool: page.close() timed out.',
+ );
+ } catch (err) {
+ log.debug('PuppeteerPool: page.close() failed.', { reason: err && err.message });
+ }
}
}
}
diff --git a/src/utils.js b/src/utils.js
index fea5440c5..6221bd54f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -335,19 +335,20 @@ export const getTypicalChromeExecutablePath = () => {
* @ignore
*/
export const addTimeoutToPromise = (promise, timeoutMillis, errorMessage) => {
- return new Promise((resolve, reject) => {
+ return new Promise(async (resolve, reject) => {
if (!isPromise(promise)) throw new Error('Parameter promise of type Promise must be provided.');
checkParamOrThrow(timeoutMillis, 'timeoutMillis', 'Number');
checkParamOrThrow(errorMessage, 'errorMessage', 'String');
const timeout = setTimeout(() => reject(new Error(errorMessage)), timeoutMillis);
- promise.then((data) => {
- clearTimeout(timeout);
+ try {
+ const data = await promise;
resolve(data);
- }, (reason) => {
+ } catch (err) {
+ reject(err);
+ } finally {
clearTimeout(timeout);
- reject(reason);
- });
+ }
});
};
diff --git a/test/puppeteer_pool.js b/test/puppeteer_pool.js
index 6252e3ab0..fddcf6b41 100644
--- a/test/puppeteer_pool.js
+++ b/test/puppeteer_pool.js
@@ -536,7 +536,7 @@ describe('PuppeteerPool', () => {
await pool.newPage();
throw new Error('Invalid error.');
} catch (err) {
- expect(err.message).to.include('useApifyProxy');
+ expect(err.stack).to.include('useApifyProxy');
}
});