Skip to content

[πŸ› Bug]: [py] CDP WebSocket connection timeout is too shortΒ #16260

Closed

Description

@nxs7

Description

The current implementation hard codes the WebSocket connection timeout for CDP to 30 seconds:

This works for most cases, but certain CDP methods can legitimately exceed this limit.

For example, HeapProfiler.takeHeapSnapshot only returns after the full snapshot has been sent via events. In my observations, on large webpages where the snapshot can exceed several hundred MBs, execution may take longer than 30 seconds. In such cases, WebSocketConnection._wait_until silently times out and returns, which in turn causes subsequent code to crash.

However, I'm not entirely sure the best way to fix the problem:

  • The most obvious solution would be to increase the timeout, but that's probably not optimal
  • Adding a parameter to the constructor WebSocketConnection would result in significant code changes, since all call sites need to be updated as well
  • Making the timeout a property could be confusing, since the constructor would still use the fixed timeout (though it likely won't hit the limit)

Reproducible Code

from selenium import webdriver
driver = webdriver.Chrome()
driver.get(<url_of_some_huge_webpage>)
devtools, connection = driver.start_devtools()
connection.on(devtools.heap_profiler.AddHeapSnapshotChunk, lambda x: print(len(x.chunk)))
connection.execute(devtools.heap_profiler.take_heap_snapshot())
driver.quit()

Activity

  1. added
    I-defectSomething is not working as intended
    A-needs-triagingA Selenium member will evaluate this soon!
    on Aug 26, 2025
  2. selenium-ci commented on Aug 26, 2025

    @selenium-ci
    Member

    @nxs7, thank you for creating this issue. We will troubleshoot it as soon as we can.

    Selenium Triage Team: remember to follow the Triage Guide

  3. navin772 commented on Aug 26, 2025

    @navin772
    Member

    Hi @nxs7, we already have a PR open to resolve this issue - #16248

  4. nxs7 commented on Aug 26, 2025

    @nxs7
    ContributorAuthor

    Great! Got it.

  5. github-actions commented on Nov 12, 2025

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

  6. locked and limited conversation to collaborators on Nov 12, 2025
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

    A-needs-triagingA Selenium member will evaluate this soon!C-pyPython BindingsI-defectSomething is not working as intendedOS-windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions