diff --git a/packages/core/src/request.ts b/packages/core/src/request.ts index edbe3f52afd4..0a5a0cd56004 100644 --- a/packages/core/src/request.ts +++ b/packages/core/src/request.ts @@ -5,7 +5,7 @@ import util from 'node:util'; import { normalizeUrl } from '@apify/utilities'; import type { Dictionary } from '@crawlee/types'; import type { BasePredicate } from 'ow'; -import ow, { ArgumentError } from 'ow'; +import ow from 'ow'; import { log as defaultLog } from './log'; import type { AllowedHttpMethods } from './typedefs'; @@ -35,11 +35,6 @@ const requestOptionalPredicates = { state: ow.optional.number.greaterThanOrEqual(0).lessThanOrEqual(6), }; -const ignoredProperties = [ - 'lockByClient', - 'lockExpiresAt', -]; - export enum RequestState { UNPROCESSED, BEFORE_NAV, @@ -146,14 +141,15 @@ export class Request { // properties and speeds up the validation cca 3-fold. // See https://github.com/sindresorhus/ow/issues/193 keys(options).forEach((prop) => { + // skip url, because it is validated above + if (prop === 'url') { + return; + } + const predicate = requestOptionalPredicates[prop as keyof typeof requestOptionalPredicates]; const value = options[prop]; if (predicate) { ow(value, `RequestOptions.${prop}`, predicate as BasePredicate); - // 'url' is checked above because it's not optional, and lockExpiresAt is ignored - } else if (prop !== 'url' && !ignoredProperties.includes(prop)) { - const msg = `Did not expect property \`${prop}\` to exist, got \`${value}\` in object \`RequestOptions\``; - throw new ArgumentError(msg, this.constructor); } });