Skip to content

[🐛 Bug]: Session still exists in Selenium Grid after Disposing RemoteWebDriver #2522

@MJB222398

Description

@MJB222398

What happened?

I have a Docker Selenium Grid and am using a RemoteWebDriver to run stuff on it. I am seeing that when I call RemoteWebDriver.Dispose() and then make an API call to get the Grid status (http://localhost:4444/status) that the session can sometimes (depending on how fast) still be seen here in the response.

Does disposing the driver not wait for the session to be properly terminated?

Command used to start Selenium Grid with Docker (or Kubernetes)

var driver = new RemoteWebDriver(
    new Uri("http://localhost:4444/wd/hub"),
    new ChromeOptions().ToCapabilities(),
    TimeSpan.FromSeconds(300));

driver.Dispose();
using var response = await new HttpClient().GetAsync("http://localhost:4444/status");
var content = await response.Content.ReadAsStringAsync();

Can see the session in this content

Relevant log output

Node logs

17:21:59.427 INFO [LocalNode.newSession] - Session created by the Node. Id: f5198aa622c0481cefd9b7d47fa2c764, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 131.0.6778.108, chrome: {chromedriverVersion: 131.0.6778.87 (ce31cae94873..., userDataDir: /home/seluser/selenium/profile}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:45497}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://localhost:4444/session..., se:cdpVersion: 131.0.6778.108, se:containerName: chrome-node, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
17:21:59.501 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://localhost:45497/devtools/browser/5f199532-e648-4eb1-b702-b5477580a703
17:22:04.041 INFO [SessionSlot.stop] - Stopping session f5198aa622c0481cefd9b7d47fa2c764

Hub logs

17:22:04.043 INFO [LocalSessionMap.remove] - Deleted session from local Session Map, Id: f5198aa622c0481cefd9b7d47fa2c764
17:22:04.043 INFO [GridModel.release] - Releasing slot for session id f5198aa622c0481cefd9b7d47fa2c764

Operating System

Ubuntu 20.04

Docker Selenium version (image tag)

4.27.0-20241204

Selenium Grid chart version (chart version)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions