Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing configuration to CheerioCrawler constructor #1432

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/cheerio-crawler/src/internals/cheerio-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { concatStreamToBuffer, readStreamToString } from '@apify/utilities';
import type { AutoscaledPoolOptions, BasicCrawlerOptions, ErrorHandler, RequestHandler } from '@crawlee/basic';
import { BasicCrawler, BASIC_CRAWLER_TIMEOUT_BUFFER_SECS } from '@crawlee/basic';
import type { CrawlingContext, EnqueueLinksOptions, ProxyConfiguration, Request, RequestQueue, Session } from '@crawlee/core';
import { CrawlerExtension, enqueueLinks, mergeCookies, Router, resolveBaseUrlForEnqueueLinksFiltering, validators } from '@crawlee/core';
import { CrawlerExtension, enqueueLinks, mergeCookies, Router, resolveBaseUrlForEnqueueLinksFiltering, validators, Configuration } from '@crawlee/core';
import type { BatchAddRequestsResult, Awaitable, Dictionary } from '@crawlee/types';
import type { CheerioRoot } from '@crawlee/utils';
import { entries, parseContentTypeFromResponse } from '@crawlee/utils';
Expand Down Expand Up @@ -404,7 +404,7 @@ export class CheerioCrawler extends BasicCrawler<CheerioCrawlingContext> {
/**
* All `CheerioCrawler` parameters are passed via an options object.
*/
constructor(options: CheerioCrawlerOptions = {}) {
constructor(options: CheerioCrawlerOptions = {}, override readonly config = Configuration.getGlobalConfig()) {
ow(options, 'CheerioCrawlerOptions', ow.object.exactShape(CheerioCrawler.optionsShape));

const {
Expand Down Expand Up @@ -437,7 +437,7 @@ export class CheerioCrawler extends BasicCrawler<CheerioCrawlingContext> {
// We need to add some time for internal functions to finish,
// but not too much so that we would stall the crawler.
requestHandlerTimeoutSecs: navigationTimeoutSecs + requestHandlerTimeoutSecs + BASIC_CRAWLER_TIMEOUT_BUFFER_SECS,
});
}, config);

this._handlePropertyNameChange({
newName: 'requestHandler',
Expand Down Expand Up @@ -716,7 +716,7 @@ export class CheerioCrawler extends BasicCrawler<CheerioCrawlingContext> {
throw new Error(`${statusCode} - ${message}`);
}

// It's not a JSON so it's probably some text. Get the first 100 chars of it.
// It's not a JSON, so it's probably some text. Get the first 100 chars of it.
throw new Error(`${statusCode} - Internal Server Error: ${body.substr(0, 100)}`);
} else if (HTML_AND_XML_MIME_TYPES.includes(type)) {
const dom = await this._parseHtmlToDom(response);
Expand Down