{"record":{"id":"fe24075f54356afa","repo":"apify/crawlee","slug":"the-request-is-not-being-processed-uniquekey-u","errorCode":null,"errorMessage":"The request is not being processed (uniqueKey: ${uniqueKey})","messagePattern":"The request is not being processed \\(uniqueKey: (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storages/request_list.ts","lineNumber":788,"sourceCode":"        }\n    }\n\n    /**\n     * Helper function that validates unique key.\n     * Throws an error if uniqueKey is not a non-empty string.\n     */\n    private ensureUniqueKeyValid(uniqueKey: string): void {\n        if (typeof uniqueKey !== 'string' || !uniqueKey) {\n            throw new Error(\"Request object's uniqueKey must be a non-empty string\");\n        }\n    }\n\n    /**\n     * Checks that a request is currently being processed and throws an error if not.\n     */\n    private ensureInProgress(uniqueKey: string): void {\n        if (!this.inProgress.has(uniqueKey)) {\n            throw new Error(`The request is not being processed (uniqueKey: ${uniqueKey})`);\n        }\n    }\n\n    /**\n     * Throws an error if request list wasn't initialized.\n     */\n    private ensureIsInitialized(): void {\n        if (!this.#isInitialized) {\n            throw new Error(\n                'RequestList is not initialized; you must call \"await requestList.initialize()\" before using it!',\n            );\n        }\n    }\n\n    /**\n     * Returns the total number of unique requests present in the `RequestList`.\n     */\n    async getTotalCount(): Promise<number> {","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/storages/request_list.ts#L770-L806","documentation":"ensureInProgress() checks the list's inProgress set before allowing markRequestAsHandled(). If the uniqueKey is not currently being processed, the request was never fetched, was already handled, or belongs to a different list, so marking it handled is invalid.","triggerScenarios":"Calling markRequestAsHandled() for a request never returned by fetchNextRequest(); calling it twice for the same request; calling it for a request from another RequestList/RequestQueue; state was restored and in-progress entries were pruned.","commonSituations":"Double-handling in retry logic without tracking; processing requests from two storage sources with one handler; worker restarts losing in-progress bookkeeping; mixing up uniqueKeys of deduplicated requests.","solutions":["Only call markRequestAsHandled with the exact request object obtained from fetchNextRequest()","Guard against double-handling with a local Set of processed uniqueKeys","Verify you are using the same RequestList instance that fetched the request","Check whether an earlier exception path already marked the request handled"],"exampleFix":"// before\nawait requestList.markRequestAsHandled(someRequest); // may be un-fetched/duplicate\n// after\nconst processed = new Set<string>();\nif (!processed.has(someRequest.uniqueKey)) {\n    await requestList.markRequestAsHandled(someRequest);\n    processed.add(someRequest.uniqueKey);\n}","handlingStrategy":"try-catch","validationCode":"if (!requestList.inProgress?.has(request.uniqueKey)) {\n  throw new Error(`Skipping ${request.uniqueKey}: not in progress`);\n}\nawait requestList.markRequestAsHandled(request);","typeGuard":"null","tryCatchPattern":"try {\n  await requestList.markRequestAsHandled(request);\n} catch (err) {\n  if (err.message.startsWith('The request is not being processed')) {\n    logger.warning(`Already handled or never fetched: ${request.uniqueKey}`); // ignore or log\n  } else throw err;\n}","preventionTips":["Track handled uniqueKeys locally to avoid double-handling","Use the same RequestList instance for fetch and mark-handled","Handle exceptions so a request isn't marked handled twice on retry paths"],"tags":["state","request-list","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}