{"record":{"id":"9b4691d0345ee6f9","repo":"apify/crawlee","slug":"the-window-property-is-not-available-skipnavi-9b4691","errorCode":null,"errorMessage":"The `window` property is not available - `skipNavigation` was used","messagePattern":"The `window` 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":248,"sourceCode":"                crawlingContext.body.toString(),\n                isXml ? 'text/xml' : 'text/html',\n            );\n\n            return {\n                window: document.defaultView,\n                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            }","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/linkedom-crawler/src/internals/linkedom-crawler.ts#L230-L266","documentation":"LinkedomCrawler mirrors JSDOMCrawler's skipNavigation design: with navigation skipped, no parse5/linkedom window is built, and the `window` property getter throws NavigationSkippedError to signal that DOM access is not possible in this mode.","triggerScenarios":"Using LinkedomCrawler with `skipNavigation: true` and then reading `context.window` in the requestHandler.","commonSituations":"Performance-tuned linkedom crawls with skipNavigation but handlers that still call window-based helpers (enqueueLinks, extractLinks); handlers shared between linkedom and normal crawlers.","solutions":["Remove `skipNavigation: true` if DOM/window access is needed.","Use `context.body` (raw string) and parse with cheerio or regex instead.","Branch the handler based on navigation-skip state before touching `window`.","Use extractLinks only on requests where the window was actually created."],"exampleFix":"// before (skipNavigation: true)\nconst links = [...context.window.document.querySelectorAll('a')];\n\n// after\nconst $ = (await import('cheerio')).load(context.body);\nconst links = $('a[href]').toArray();","handlingStrategy":"try-catch","validationCode":"if (request.skipNavigation === true) {\n    // context.window will throw; use cheerio on context.body instead\n}","typeGuard":"function isNavigationSkippedError(err: unknown): err is Error & { name: 'NavigationSkippedError' } {\n    return err instanceof Error && err.name === 'NavigationSkippedError';\n}","tryCatchPattern":"try {\n    const { window } = context;\n    parse(window);\n} catch (err) {\n    if ((err as Error).message.includes('`skipNavigation` was used')) {\n        parseCheerio(context.body);\n    } else {\n        throw err;\n    }\n}","preventionTips":["Guard all window access behind a skipNavigation check.","Use separate handlers for skipNavigation vs parsing crawls.","Store skipNavigation flag in request.userData for easy branching.","Add tests that exercise handlers in both navigation modes."],"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"}