{"record":{"id":"e6a9e98ddfa38310","repo":"apify/crawlee","slug":"alwaysenqueue-cannot-be-used-together-with-a-cus","errorCode":null,"errorMessage":"`alwaysEnqueue` cannot be used together with a custom `uniqueKey`.","messagePattern":"`alwaysEnqueue` cannot be used together with a custom `uniqueKey`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/request.ts","lineNumber":220,"sourceCode":"            skipNavigation,\n            enqueueStrategy,\n            crawlDepth,\n        } = options as RequestOptions & {\n            loadedUrl?: string;\n            retryCount?: number;\n            sessionId?: string;\n            errorMessages?: string[];\n            handledAt?: string | Date;\n        };\n\n        let { method = 'GET' } = options;\n\n        method = method.toUpperCase() as AllowedHttpMethods;\n\n        if (method === 'GET' && payload) throw new Error('Request with GET method cannot have a payload.');\n\n        if (uniqueKey && alwaysEnqueue) {\n            throw new Error('`alwaysEnqueue` cannot be used together with a custom `uniqueKey`.');\n        }\n\n        this.id = id;\n        this.url = url;\n        this.loadedUrl = loadedUrl;\n        this.uniqueKey =\n            uniqueKey ||\n            CrawleeRequest.computeUniqueKey({\n                url,\n                method,\n                payload,\n                keepUrlFragment,\n                useExtendedUniqueKey,\n                alwaysEnqueue,\n            });\n        this.method = method;\n        this.payload = payload;\n        this.noRetry = noRetry;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/request.ts#L202-L238","documentation":"A custom uniqueKey deduplicates the request by that key, while alwaysEnqueue forces the request to be enqueued regardless of deduplication — the two are contradictory, so the Request constructor throws when both are provided.","triggerScenarios":"new Request({ url, uniqueKey: 'my-key', alwaysEnqueue: true }).","commonSituations":"Copy-pasting options from different call sites; enabling alwaysEnqueue globally for retries while requests also carry uniqueKeys; misunderstanding that uniqueKey already controls dedup behavior.","solutions":["Remove alwaysEnqueue if you want deduplication via uniqueKey","Remove uniqueKey if you truly want every occurrence enqueued","Generate uniqueKey per occurrence (e.g. include a nonce) instead of using alwaysEnqueue"],"exampleFix":"// before\nnew Request({ url, uniqueKey: 'item-1', alwaysEnqueue: true });\n// after\nnew Request({ url, uniqueKey: 'item-1' });","handlingStrategy":"validation","validationCode":"if (opts.uniqueKey && opts.alwaysEnqueue) throw new Error('uniqueKey and alwaysEnqueue are mutually exclusive');","typeGuard":null,"tryCatchPattern":"try {\n  return new Request(opts);\n} catch (err) {\n  if (err.message.includes('alwaysEnqueue')) {\n    const { alwaysEnqueue, ...rest } = opts;\n    return new Request(rest);\n  }\n  throw err;\n}","preventionTips":["Decide per request: dedup via uniqueKey OR force-enqueue, never both","Document the mutual exclusivity in request factory helpers","Review global alwaysEnqueue flags that conflict with keyed requests"],"tags":["request","configuration","validation"],"backgroundTag":"conflicting-request-options","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}