Skip to content

asyncio errors during cleanup if there are multiple CDP drivers present #3689

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

Closed
mdmintz opened this issue Apr 22, 2025 · 2 comments · Fixed by #3690
Closed

asyncio errors during cleanup if there are multiple CDP drivers present #3689

mdmintz opened this issue Apr 22, 2025 · 2 comments · Fixed by #3690
Assignees
Labels
bug Uh oh... Something needs to be fixed UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@mdmintz
Copy link
Member

mdmintz commented Apr 22, 2025

asyncio errors during cleanup if there are multiple CDP drivers present.

Eg. ERROR:asyncio:Task was destroyed but it is pending!

This is a regression in 4.37.4. (This fixed the memory leak)

To reproduce:

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url1 = "https://seleniumbase.io/demo_page"
    sb.activate_cdp_mode(url1)
    driver1 = sb.driver
    url2 = "https://seleniumbase.io/coffee/"
    driver2 = sb.get_new_driver(undetectable=True)
    sb.activate_cdp_mode(url2)
    print(driver1.get_current_url())
    print(driver2.get_current_url())
    sb.switch_to_default_driver()
    sb.assert_url_contains("demo_page")
    print(sb.get_current_url())
    sb.switch_to_driver(driver2)
    sb.assert_url_contains("coffee")
    print(sb.get_current_url())

Need to fix this without reverting the fix to the memory leak.

@mdmintz mdmintz added bug Uh oh... Something needs to be fixed UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels Apr 22, 2025
@mdmintz mdmintz self-assigned this Apr 22, 2025
@mdmintz
Copy link
Member Author

mdmintz commented Apr 22, 2025

It seems that removing await asyncio.sleep(0.015) from aclose() in seleniumbase/undetected/cdp_driver/connection.py resolves the issue.

@mdmintz
Copy link
Member Author

mdmintz commented Apr 22, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh oh... Something needs to be fixed UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant