Skip to content

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

Closed
Adi1231234 wants to merge 1 commit intocombined-fixesfrom
fix/inject-navigation-resilience
Closed

fix: make inject() resilient to page navigation during initialization#22
Adi1231234 wants to merge 1 commit intocombined-fixesfrom
fix/inject-navigation-resilience

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

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

1 participant