Skip to content

fix: make inject() resilient to page navigation during initialization#21

Closed
Adi1231234 wants to merge 11 commits intocombined-fixesfrom
fix/inject-navigation-resilience-upstream
Closed

fix: make inject() resilient to page navigation during initialization#21
Adi1231234 wants to merge 11 commits intocombined-fixesfrom
fix/inject-navigation-resilience-upstream

Conversation

@Adi1231234
Copy link
Copy Markdown
Owner

Summary

inject() uses page.evaluate() in polling loops to wait for window.Debug?.VERSION and window.Store. After sleep/resume, Chrome may perform an internal page navigation (IndexedDB recovery) that destroys the execution context, causing page.evaluate() to throw.

This PR:

  • Replaces the two manual page.evaluate() polling loops with page.waitForFunction(), which natively survives execution context destruction
  • Moves the framenavigated listener registration to before inject() in initialize()

Also submitted upstream: wwebjs#127083

Test plan

  • 11 E2E tests passing (A/B comparison + navigation resilience)

🤖 Generated with Claude Code

adrianliz and others added 11 commits February 6, 2026 14:06
* New property isLocked

* New property isLocked
Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>
Replace manual evaluate-based polling loops with waitForFunction,
which natively survives execution context destruction caused by
page navigation (e.g. Chrome's internal IndexedDB recovery after
system sleep/resume).

Also move the framenavigated listener registration before the
initial inject() call, so navigation events during inject are
handled by the existing listener.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Adi1231234 Adi1231234 closed this Feb 28, 2026
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.

5 participants