apify/crawlee · error · NavigationSkippedError

The `contentType` property is not available - `skipNavigatio

Error message

The `contentType` property is not available - `skipNavigation` was used

What it means

NavigationSkippedError thrown by the getter for `contentType` on the crawling context. Since `skipNavigation` requests are never fetched, there is no Content-Type to expose; the getter throws to surface misuse immediately.

Source

Thrown at packages/http-crawler/src/internals/http-crawler.ts:557

            `Navigation timed out after ${this.#navigationTimeoutMillis / 1000} seconds.`,
        );
        tryCancel();

        request.loadedUrl = httpResponse?.url;
        request.state = RequestState.AFTER_NAV;

        return { request: request as LoadedRequest<CrawleeRequest>, response: httpResponse };
    }

    private async processHttpResponse(
        crawlingContext: CrawlingContextWithResponse,
    ): Promise<
        Omit<InternalHttpCrawlingContext, keyof CrawlingContextWithResponse> & Partial<InternalHttpCrawlingContext>
    > {
        if (crawlingContext.request.skipNavigation) {
            return {
                get contentType(): InternalHttpCrawlingContext['contentType'] {
                    throw new NavigationSkippedError(
                        'The `contentType` property is not available - `skipNavigation` was used',
                    );
                },
                get body(): InternalHttpCrawlingContext['body'] {
                    throw new NavigationSkippedError(
                        'The `body` property is not available - `skipNavigation` was used',
                    );
                },
                get json(): InternalHttpCrawlingContext['json'] {
                    throw new NavigationSkippedError(
                        'The `json` property is not available - `skipNavigation` was used',
                    );
                },
                get waitForSelector(): InternalHttpCrawlingContext['waitForSelector'] {
                    throw new NavigationSkippedError(
                        'The `waitForSelector` method is not available - `skipNavigation` was used',
                    );
                },

View on GitHub (pinned to dbe57fb09c)

Solutions

  1. Check `request.skipNavigation` before accessing `contentType`.
  2. Hardcode or infer the type from the URL/request metadata for skipped requests.
  3. Use a separate handler (e.g. via label routing) for skipNavigation requests.

Example fix

// before
if (context.contentType?.includes('json')) { parseJson(context.body); }
// after
if (!context.request.skipNavigation && context.contentType?.includes('json')) { parseJson(context.body); }
Defensive patterns

Strategy: type-guard

Validate before calling

if (!request.skipNavigation && ctx.contentType) { branchOnType(ctx.contentType); }

Type guard

function hasContentType(ctx: CrawlingContext): boolean { return !(ctx.request as any).skipNavigation; }

Try / catch

try { const ct = ctx.contentType; } catch (err) { if (err instanceof NavigationSkippedError) { /* infer from url or userData */ } else throw err; }

Prevention

When it happens

Trigger: Reading `context.contentType` in a request handler for a request marked `skipNavigation: true`.

Common situations: Handlers that branch on content type (HTML vs JSON parsing) without checking whether navigation happened; shared parse utilities assuming a fetched response.

Related errors


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/109fc985bdab51ea. Report an issue: GitHub.