Skip to content

Socket exception makes it impossible to cleanly close session #31

@bch36

Description

@bch36

If there's an issue that closes the WebSocket connection, it's not longer possible to cleanly close the session.

If you call Session::close() on the session object after an issue that closes the WebSocket connection (likely after catching an exception resulting from that closed WebSocket connection), Session::close() will attempt to send messages to the disconnected WebSocket. That will cause an exception.

If you catch that exception, execution in Session::close() will never get to the line that closes the DevtoolsClient: "$this->browser->close();"

If DevtoolsClient::close() is never called, the LogicException in DevtoolsClient::__destruct() will be thrown, complaining that the (broken) WebSocket connection was never released.

Put another way:

  1. Instance::open() creates a Tab. You can create and get the DevtoolsClient using $tab->devtools(). You can call $devtools->close() directly.
  2. On the other hand, Instance::createSession() creates a Session. The DevtoolsClient is created implicitly, and you cannot get it. You can only close in indirectly by closing the Session, and if the Session closing process throws an exception, code execution will never reach the line in Session::close() that calls DevtoolsClient::close(). This results in DevtoolsClient::__destruct() throwing the exception seen inside.

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