{"record":{"id":"14552583f9aa4c5a","repo":"apify/crawlee","slug":"the-body-property-is-not-available-skipnaviga-145525","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/linkedom-crawler/src/internals/linkedom-crawler.ts","lineNumber":254,"sourceCode":"                get body() {\n                    return document.documentElement.outerHTML;\n                },\n                get document() {\n                    // See comment about typing in LinkeDOMCrawlingContext definition\n                    return document as unknown as Document;\n                },\n            };\n        } catch (err) {\n            if (err instanceof NavigationSkippedError) {\n                return {\n                    get window(): Window {\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: Window }) {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/linkedom-crawler/src/internals/linkedom-crawler.ts#L236-L272","documentation":"In LinkedomCrawler skipNavigation mode the `body` getter, which would normally return the parsed document HTML, is replaced by a throwing getter since no document was produced. It preserves the NavigationSkippedError as the cause for diagnosis.","triggerScenarios":"Reading `context.body` in a LinkedomCrawler requestHandler for a request run with `skipNavigation: true`.","commonSituations":"Handlers written for the default (parsing) mode reused on skipNavigation crawls; confusion with CheerioCrawler, where `context.body` is always the raw HTML string.","solutions":["Disable skipNavigation so the linkedom document (and its `body` getter) is created.","Obtain the raw response text from the response object instead of `context.body`.","Switch these requests to CheerioCrawler if you only need raw HTML handling.","Guard DOM/body access with a check on whether navigation was skipped."],"exampleFix":"// before (skipNavigation: true)\nconst html = context.body; // throws\n\n// after\nconst html = context.response?.body ?? ''; // raw source, not the DOM body getter","handlingStrategy":"try-catch","validationCode":"if (request.skipNavigation === true) {\n    // use context.response for raw HTML; context.body getter throws\n}","typeGuard":"null","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();\n    } else {\n        throw err;\n    }\n}","preventionTips":["Don't reuse JSDOMCrawler-style `context.body` assumptions in skipNavigation linkedom handlers.","Fetch raw HTML via the response object in skipNavigation mode.","Prefer CheerioCrawler when raw HTML access is the primary need.","Note the skipNavigation contract in team docs: no window/body/document getters."],"tags":["linkedom","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"}