{"record":{"id":"29d99044bad58266","repo":"apify/crawlee","slug":"the-body-property-is-not-available-skipnaviga-29d990","errorCode":null,"errorMessage":"The `body` property is not available - `skipNavigation` was used","messagePattern":"The `body` property is not available - `skipNavigation` was used","errorType":"exception","errorClass":"NavigationSkippedError","httpStatus":null,"severity":"error","filePath":"packages/jsdom-crawler/src/internals/jsdom-crawler.ts","lineNumber":371,"sourceCode":"                window,\n                get body() {\n                    return window.document.documentElement.outerHTML;\n                },\n                get document() {\n                    return window.document;\n                },\n            };\n        } catch (err) {\n            if (err instanceof NavigationSkippedError) {\n                return {\n                    get window(): DOMWindow {\n                        throw new NavigationSkippedError(\n                            'The `window` property is not available - `skipNavigation` was used',\n                            { cause: err },\n                        );\n                    },\n                    get body(): string {\n                        throw new NavigationSkippedError(\n                            'The `body` property is not available - `skipNavigation` was used',\n                            { cause: err },\n                        );\n                    },\n                    get document(): Document {\n                        throw new NavigationSkippedError(\n                            'The `document` property is not available - `skipNavigation` was used',\n                            { cause: err },\n                        );\n                    },\n                };\n            }\n\n            throw err;\n        }\n    }\n\n    private async addHelpers(crawlingContext: InternalHttpCrawlingContext & { body: string; window: DOMWindow }) {","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/jsdom-crawler/src/internals/jsdom-crawler.ts#L353-L389","documentation":"In skipNavigation mode the response is never loaded into a DOM, so even the convenience `body` getter is replaced by a throwing getter. Unlike the normal path (where `body` returns document.documentElement.outerHTML), skipNavigation requests expose no parsed representation through this context object.","triggerScenarios":"Reading `context.body` in a JSDOMCrawler requestHandler while the request was run with `skipNavigation: true`.","commonSituations":"Handlers that default to using `context.body` for HTML parsing but are attached to a crawler instance configured with skipNavigation; copy-pasted handlers between JSDOMCrawler and CheerioCrawler (CheerioCrawler's `body` works fine).","solutions":["Disable `skipNavigation` so the JSDOM is created and `body` is populated.","If skipNavigation is required, consume the raw response via `context.response` / fetch results instead of `context.body`.","Use CheerioCrawler for such requests if only HTML string parsing is needed.","Guard handler code to only read `body` when navigation was not skipped."],"exampleFix":"// before (skipNavigation: true)\nconst { window } = context;\nconst html = context.body;\n\n// after\nconst html = context.response?.body ?? ''; // raw bytes from the response, not the DOM body getter","handlingStrategy":"try-catch","validationCode":"if (request.skipNavigation === true) {\n    // `context.body` getter will throw; use context.response instead\n}","typeGuard":"function canReadDomBody(ctx: { body?: unknown }): ctx is { body: string } {\n    return ctx.body !== undefined;\n}","tryCatchPattern":"let html: string;\ntry {\n    html = context.body;\n} catch (err) {\n    if ((err as Error).message.includes('`skipNavigation` was used')) {\n        html = await context.response.text(); // raw source fallback\n    } else {\n        throw err;\n    }\n}","preventionTips":["In skipNavigation mode, read the response object, not DOM properties.","Document in handler comments that `body`/`window`/`document` getters throw under skipNavigation.","Prefer CheerioCrawler for raw-HTML-only workloads.","Type your context narrowly so DOM getters are not part of the skipNavigation path."],"tags":["jsdom","skip-navigation","dom","api-misuse"],"backgroundTag":"dom-unavailable-skip-navigation","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}