{"record":{"id":"91f49a679b7c84e8","repo":"CloakHQ/CloakBrowser","slug":"humanized-dom-read-requires-an-active-isolated-wor-91f49a","errorCode":null,"errorMessage":"Humanized DOM read requires an active isolated world","messagePattern":"Humanized DOM read requires an active isolated world","errorType":"exception","errorClass":"StealthWorldUnavailableError","httpStatus":null,"severity":"error","filePath":"js/src/human/scroll.ts","lineNumber":48,"sourceCode":"function isInViewport(\n  bounds: ElementBounds,\n  viewportHeight: number,\n  cfg: HumanConfig,\n): boolean {\n  const topEdge = bounds.y;\n  const bottomEdge = bounds.y + bounds.height;\n  const zoneTop = viewportHeight * cfg.scroll_target_zone[0];\n  const zoneBottom = viewportHeight * cfg.scroll_target_zone[1];\n  return topEdge >= zoneTop && bottomEdge <= zoneBottom;\n}\n\nconst SCROLL_JS =\n  '(() => { const e = document.scrollingElement || document.documentElement;' +\n  ' return { y: window.scrollY, maxY: Math.max(0, e.scrollHeight - e.clientHeight) }; })()';\n\nasync function readScrollState(page: Page): Promise<{ y: number; maxY: number }> {\n  const world = getWorld(page);\n  if (!world) throw new StealthWorldUnavailableError();\n  try {\n    const state = await world.evaluate(SCROLL_JS);\n    if (\n      !state || typeof state !== 'object' ||\n      typeof state.y !== 'number' || typeof state.maxY !== 'number'\n    ) {\n      throw new StealthEvaluationError('<scroll-state>');\n    }\n    return state;\n  } catch (error) {\n    if (error instanceof StealthEvaluationError) throw error;\n    throw new StealthEvaluationError('<scroll-state>');\n  }\n}\n\nasync function smoothWheel(raw: RawMouse, delta: number, cfg: HumanConfig): Promise<void> {\n  const absD = Math.abs(delta);\n  const sign = delta > 0 ? 1 : -1;","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/CloakHQ/CloakBrowser/blob/d6bad5de261bedf025280ace1d14e800aee13923/js/src/human/scroll.ts#L30-L66","documentation":"Humanized scrolling needs to read window.scrollY and the document's scroll metrics from inside the isolated (stealth) world via getWorld(page).evaluate. If no world is registered on the page (getWorld returns undefined), readScrollState throws this error before attempting any evaluation. It signals the humanizer was used on a page where its isolated world was never installed.","triggerScenarios":"Calling scrollToElement, scrollByHuman, or any humanized action that scrolls (click/press paths calling readScrollState) on a Page that was not set up with the stealth/isolated-world injection (e.g. a plain page.create() without the library's page patching, or after the world was torn down).","commonSituations":"Creating pages manually instead of through the library's browser wrapper; using humanized APIs after context.close()/world cleanup; running against a remotely connected browser (playwright.chromium.connectTo) where the injection step was skipped; version upgrade changing how pages get patched.","solutions":["Create the page through the library's provided API (browser.newPage wrapper / withStealth / init call) so the isolated world is injected.","Ensure humanized scroll-dependent actions are only used while the page/context the world was installed on is still open.","Re-initialize the world on the current page with the library's setup function before calling human actions.","If you don't need humanization for this action, call the plain Playwright scrollIntoView/click instead."],"exampleFix":"// before\nconst page = await context.newPage(); // no isolated world installed\nawait scrollToElement(page, raw, 'text=Footer');\n\n// after\nconst page = await openHumanPage(browser); // library wrapper that installs the world\nawait scrollToElement(page, raw, 'text=Footer');","handlingStrategy":"validation","validationCode":"import { getWorld } from './human/world';\nif (!getWorld(page)) throw new Error('Open the page via openHumanPage() before humanized actions');\nawait scrollToElement(page, raw, selector);","typeGuard":"import { getWorld } from './human/world';\nfunction hasHumanWorld(page: Page): boolean {\n  return getWorld(page) !== undefined;\n}","tryCatchPattern":"try {\n  await scrollToElement(page, raw, selector);\n} catch (e) {\n  if (e instanceof StealthWorldUnavailableError) {\n    const page2 = await openHumanPage(browser); // re-create with world\n    await scrollToElement(page2, raw, selector);\n  } else throw e;\n}","preventionTips":["Always create pages through the library's wrapper, never raw context.newPage().","Set an explicit fixture/beforeEach that installs the world on every new page.","Never call humanized APIs after context.close() or world teardown."],"tags":["playwright","isolated-world","scroll","initialization","humanize"],"backgroundTag":"missing-browser-context-initialization","analyzedSha":"d6bad5de261bedf025280ace1d14e800aee13923","analyzedAt":"2026-08-28T14:13:12.918Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}