Skip to content

fix(page): drop cached node ids after DOM.getDocument - #656

Merged
route merged 2 commits into
mainfrom
fix/document-node-id-invalidation
Oct 18, 2026
Merged

route merged 2 commits into
mainfrom
fix/document-node-id-invalidation

Conversation

@route

@route route commented Oct 18, 2026

Copy link
Copy Markdown
Member

DOM.getDocument resets every node id on the target, across all frames, without firing DOM.documentUpdated, so the document version from #653 didn't change and nodes kept a dead id. Every later focus, click, scroll_into_view and so on raised NodeNotFoundError on a node that was still on the page. Ferrum sends getDocument from:

  • frame.content=. Only the iframe case matters, because on the main frame document.open removes the old nodes anyway.
  • accessibility.query without a node.
  • page.document_node_id.
  • its own handler for the main frame's frameStoppedLoading, so a node found while the page was still loading broke once loading finished.

document_node_id now bumps document_version after it sends the command, and nodes request their id again. Bumping before the send could let a racing requestNode save an id that the getDocument right behind it invalidates.

When DOM.requestNode returns 0 (a new document committed, but Ferrum hasn't requested it yet, i.e. a navigation nobody waited for), the error now says the page is still loading a new document instead of only "node is not trackable". It doesn't retry: a getDocument there would hide the race and invalidate everyone else's ids, and Capybara's synchronize already retries ObsoleteNode until the page finishes loading.

Refs #650

route added 2 commits October 18, 2026 21:19
DOM.getDocument resets every node id on the target without firing DOM.documentUpdated, so nodes found before
frame.content= on an iframe, a whole-page accessibility.query or the document request on frameStoppedLoading
kept a dead id and raised NodeNotFoundError. Bump document_version after it so their ids are requested again.

Refs #650
@route
route merged commit f67dfe8 into main Oct 18, 2026
7 checks passed
@route
route deleted the fix/document-node-id-invalidation branch October 18, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant