8000 feat(browser): add wait-for-selector/condition to avoid post-navigation hydration races · Issue #4 · Mnehmos/mnehmos.ooda.mcp · GitHub
[go: up one dir, main page]

Skip to content
8000

feat(browser): add wait-for-selector/condition to avoid post-navigation hydration races #4

Open

Description

@Mnehmos

Summary

After navigate_page, the first evaluate_js frequently runs before the SPA has hydrated, so it reads a pre-render state (in my case the app reported ply 0 / 0 overlay elements), and I had to fire the same script a second time to get real results. There's no wait primitive beyond navigate_page's own load wait, which fires on document load — before client-side React has mounted/hydrated.

Repro shape

navigate_page("http://localhost:5173")
evaluate_js(/* query app state */)  // returns empty / initial — app not hydrated yet
evaluate_js(/* same query */)       // now returns real state

Suggested fix

Add a wait primitive so callers can block on app-ready instead of guess-and-retry:

  • wait_for_selector(selector, { timeout }) (Playwright page.waitForSelector), and/or
  • wait_for_function(jsExpression, { timeout }) (Playwright page.waitForFunction), and/or
  • a waitFor: { selector | function | networkidle } option on navigate_page itself.

networkidle alone isn't sufficient for SPAs; a selector/function predicate is the reliable signal.

Environment

  • Engine: Playwright, headless.
  • App: Vite + React dev server.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0