alibaba/page-agent · warning

Error checking text node visibility:

Error message

Error checking text node visibility:

What it means

During DOM tree construction, isTextNodeVisible wraps visibility checks (checkVisibility plus a getComputedStyle fallback) in try/catch; any unexpected exception while inspecting a text node's parent logs this warning and the node is treated as invisible. It is a non-fatal warning so one bad node never breaks the whole page extraction.

Source

Thrown at packages/page-controller/src/dom/dom_tree/index.js:632

				return false
			}

			// Check parent visibility
			const parentElement = textNode.parentElement
			if (!parentElement) return false

			try {
				return parentElement.checkVisibility({
					checkOpacity: true,
					checkVisibilityCSS: true,
				})
			} catch (e) {
				// Fallback if checkVisibility is not supported
				const style = window.getComputedStyle(parentElement)
				return style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0'
			}
		} catch (e) {
			console.warn('Error checking text node visibility:', e)
			return false
		}
	}

	/**
	 * Checks if an element is accepted.
	 *
	 * @param {HTMLElement} element - The element to check.
	 * @returns {boolean} Whether the element is accepted.
	 */
	function isElementAccepted(element) {
		if (!element || !element.tagName) return false

		// Always accept body and common container elements
		const alwaysAccept = new Set([
			'body',
			'div',
			'main',

View on GitHub (pinned to d02db1ee7c)

Solutions

  1. Treat as benign: the node is skipped, extraction continues; verify your extraction still contains the content you need
  2. If content is missing, re-run updateTree() when the page is more settled (after load/spinner completes)
  3. Upgrade to a modern browser so checkVisibility is used instead of the throwing fallback
  4. If it floods logs, debounce updateTree calls and avoid indexing during heavy DOM mutation
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: The parent element is in a detached document or a cross-origin iframe where getComputedStyle/checkVisibility throws; exotic or polyfilled DOM environments; nodes removed mid-traversal so their parent becomes null; jsdom or other non-browser DOM lacking full APIs.

Common situations: Pages with cross-origin iframes; heavy mutation during scraping causing races; test environments (jsdom) with partial CSSOM support; older browsers without checkVisibility where the fallback itself throws.

Related errors


AI-assisted analysis of alibaba/page-agent@d02db1ee7c (2026-08-28). Data as JSON: /api/errors/c16cc5110109f1ed. Report an issue: GitHub.