Skip to content

[nodriver] Running in headless mode causes infinite loop on 0.45+ #2182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
szdc opened this issue Apr 23, 2025 · 1 comment
Open

[nodriver] Running in headless mode causes infinite loop on 0.45+ #2182

szdc opened this issue Apr 23, 2025 · 1 comment

Comments

@szdc
Copy link

szdc commented Apr 23, 2025

I'm running 0.45.2 but this bug appears to affect versions 0.45+

Running in headed mode works:

browser = await nodriver.start(headless=False)
tab = await self._browser.get("https://www.google.com")

Running in headless mode fails due to an infinite loop:

browser = await nodriver.start(headless=True)
tab = await self._browser.get("https://www.google.com")

Stack trace:

  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/connection.py", line 518, in _send_oneshot
    return await self.send(cdp_obj, _is_update=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/tab.py", line 202, in send
    await self._prepare_headless()
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/tab.py", line 211, in _prepare_headless
    resp = await self._send_oneshot(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/connection.py", line 518, in _send_oneshot
    return await self.send(cdp_obj, _is_update=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/tab.py", line 202, in send
    await self._prepare_headless()
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/tab.py", line 211, in _prepare_headless
    resp = await self._send_oneshot(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/connection.py", line 518, in _send_oneshot
    return await self.send(cdp_obj, _is_update=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/szdc/Documents/code/nodriver_example/.venv/lib/python3.13/site-packages/nodriver/core/tab.py", line 202, in send
    await self._prepare_headless()
  File "...", line -1, in [rest of traceback truncated]
RecursionError: maximum recursion depth exceeded

The root cause here appears to be this commit that added a send method to the Tab class that overrides Connection.send:

  1. Tab.send calls _prepare_headless
  2. _prepare_headless calls _send_oneshot, a method on the Connection base class
  3. _send_oneshot calls send, which is the method on Tab, not Connection
  4. Go to 1; the cycle continues

I'm not a collaborator so I can't submit a pull request, but you could fix this by calling the base send method directly: ultrafunkamsterdam/nodriver@main...szdc:nodriver:main

@ultrafunkamsterdam
Copy link
Owner

Ah yeah good catch. Some things have changed and this has slipped attention. Will fix today

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

No branches or pull requests

2 participants