fierDeToiMonGrand
08/30/2026, 1:12 AMCheerioCrawler and need a way to conditionally drop/abort requests that are already in the RequestQueue when a runtime condition is met.
The goal is to completely discard the request so it:
- Does not make the network request.
- Does not execute the requestHandler.
- Does not count as a failed request or log an error.
## What I tried
### 1. Throwing a custom error in preNavigationHooks
ts
preNavigationHooks: [
async ({ request }) => {
if (shouldAbortRequest(request)) {
request.noRetry = true;
throw new CustomAbortError();
}
},
]
I also swallow the error in errorHandler and failedRequestHandler.
Problem: Crawlee still marks the request as FAILED, logs Request failed and reached maximum retries, and increments failed request metrics.
### 2. Using request.skipNavigation = true
ts
preNavigationHooks: [
async ({ request }) => {
if (shouldAbortRequest(request)) {
request.skipNavigation = true;
}
},
]
Problem: This skips the HTTP request, but requestHandler still executes unless I add manual guard logic.
## Question
Is there an official/idiomatic way to completely cancel an enqueued request so it is silently discarded without:
- Making the network request.
- Running the route/request handler.
- Being treated as a failed request.
Thanks!Answer Overflow
08/30/2026, 1:12 AMApifyBot
08/30/2026, 1:12 AMFukami
09/02/2026, 1:37 PMFukami
09/02/2026, 1:38 PMProcessing ${request.url});
},
});Fukami
09/02/2026, 1:38 PMFukami
09/02/2026, 1:38 PMFukami
09/02/2026, 1:38 PMFukami
09/02/2026, 1:38 PMfierDeToiMonGrand
09/02/2026, 3:26 PM