Skip to content

RuntimeError("Timeout should be used inside a task") in Stealthy Playwright Mode #4302

@mdmintz

Description

@mdmintz

RuntimeError("Timeout should be used inside a task") in Stealthy Playwright Mode.

There was also this: RuntimeWarning: coroutine 'Event.wait' was never awaited.


Stack trace:

Traceback (most recent call last):
  File "<REDACTED>", line 22, in <module>
    sb.click(selector)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michael/github/SeleniumBase/seleniumbase/core/sb_cdp.py", line 837, in click
    element.click()  # Standard CDP click
    ~~~~~~~~~~~~~^^
  File "/Users/michael/github/SeleniumBase/seleniumbase/core/sb_cdp.py", line 60, in <lambda>
    element.click = lambda: self.__click(element)
                            ~~~~~~~~~~~~^^^^^^^^^
  File "/Users/michael/github/SeleniumBase/seleniumbase/core/sb_cdp.py", line 487, in __click
    self.loop.run_until_complete(self.page.wait(0.2))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michael/.virtualenvs/playwright/lib/python3.14/site-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
           ~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/futures.py", line 208, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/tasks.py", line 289, in __step_run_and_handle_result
    result = coro.send(None)
  File "/Users/michael/github/SeleniumBase/seleniumbase/undetected/cdp_driver/connection.py", line 316, in wait
    await asyncio.wait_for(
        self.listener.idle.wait(), timeout=t
    )
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/timeouts.py", line 88, in __aenter__
    raise RuntimeError("Timeout should be used inside a task")
RuntimeError: Timeout should be used inside a task
<sys>:0: RuntimeWarning: coroutine 'Event.wait' was never awaited

It may be related to using nest-asyncio since this only happens with Stealthy Playwright Mode and not regular CDP Mode.

Metadata

Metadata

Assignees

Labels

UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModebugUh oh... Something needs to be fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions