-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: Selenium driver (C#) doesn't clean up session if timing out when creating session? #14743
Comments
@genne, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
It is impossible to dispose a session which doesn't exists. Why the session could not be created in time... this should be resolved. @genne any ideas? |
@nvborisenko perhaps instead of relying on the session id returned by the endpoint, you include a request id (GUID) when creating the session? Then you can use that to kill the session? var requestId = Guid.New();
parameters["RequestId"] = requestId;
try
{
Response response = this.Execute(DriverCommand.NewSession, parameters);
}
catch
{
var quitParameters = new()...;
quitParameters["RequestId"] = requestId;
this.Execute(DriverCommand.Quit, quitParameters);
} |
@diemol from one point of you it works as expected. It is normal just to close this issue. But from other point of view the issue looks like an issue and, seems, it is valid. |
@nvborisenko This might be an issue of unaligned timeouts? It is in general a good idea to have a client timeout >300s, see #12368 (comment) |
We can increase default timeout, but it is not a solution :( The issue here is about how to determine that client is offline, and server can clean up all resources potentially allocated by the client. |
I have recently added canceling the upstream request in 7175349 so the grid should be able to stop the new session request without a request id. |
So it should be implicitly fixed in the next release of Grid? |
Maybe, it depends on how the webdriver does handle the client closing the socket before the browser has been started. In case the webdriver does not propper handle this, the grid could handle it. |
I have created |
@joerg1985 @nvborisenko thanks for the quick fix ⭐ |
Hi @joerg1985 @nvborisenko the latest version doesn't work for me anymore, I get a timeout error every time I try to connect: |
Just restarting the container seems to have fixed it. |
What happened?
I often encounter timeout errors when attempting to create sessions:
At the same time, I notice the grid queue builds up, and the sessions seem to run for a couple of minutes before being closed:
From analyzing the code, it appears that StartSession doesn’t clean up properly when it fails:
If this throws an exception, the sessionId is never set:
As a result, Dispose does nothing:
The session is still created, but since the session ID is never returned to the client, it remains stuck until it’s automatically terminated after a few minutes. This also causes subsequent sessions to time out as they wait for the hung session, which further compounds the issue by adding more stuck sessions to the queue.
How can we reproduce the issue?
Relevant log output
Operating System
Both macOS 14.6.1 and Linux
Selenium version
C# 4.24.0
What are the browser(s) and version(s) where you see this issue?
Chrome
What are the browser driver(s) and version(s) where you see this issue?
Selenium.WebDriver.ChromeDriver 130.0.6723.11600
Are you using Selenium Grid?
4.26.0 (revision 69f9e5e)
The text was updated successfully, but these errors were encountered: