Background
As you may know, there is a long standing issue with geckodriver that Firefox does not exit when geckodriver is terminated. The issue does not surface when a normal session close/quit is performed. In this case, a DELETE is sent to geckodriver and Firefox is shut down. However, if a session times out, OsProcess#destroy kills geckodriver only with an OS signal. And due to the aforementioned issue, Firefox itself is not killed.
Ideally, the geckodriver bug would be fixed. However, since it is a 5 year old bug with resolution being postponed from release to release I don't think this will be resolved in geckodriver itself any time soon.
Proposal
The geckodriver codebase is not anywhere near my skillset, but the Selenium codebase is. If appreciated, I would like to contribute a fix such that org.openqa.selenium.remote.service.DriverService#stop is changed such that in the GeckoDriverService a "hook" is called to shut down geckodriver and Firefox by sending a DELETE to the session.
Note that the `` already contains related code:
URL killUrl = new URL(url.toString() + "/shutdown");
new UrlChecker().waitUntilUnavailable(3, SECONDS, killUrl);
However, geckodriver does not have such a /shutdown endpoint. An approach could be to factor this code out into a separate method and to override it in GeckoDriverService by sending an HTTP DELETE request to the /{session-id} endpoint.
DELETE on stop as default behaviour?
Note that I don't really know why this isn't default behaviour. org.openqa.selenium.grid.node.ProtocolConvertingSession already always forwards DELETE requests. But maybe there are other implementations that I'm not aware of though.
Background
As you may know, there is a long standing issue with geckodriver that Firefox does not exit when geckodriver is terminated. The issue does not surface when a normal session close/quit is performed. In this case, a DELETE is sent to geckodriver and Firefox is shut down. However, if a session times out,
OsProcess#destroykills geckodriver only with an OS signal. And due to the aforementioned issue, Firefox itself is not killed.Ideally, the geckodriver bug would be fixed. However, since it is a 5 year old bug with resolution being postponed from release to release I don't think this will be resolved in geckodriver itself any time soon.
Proposal
The geckodriver codebase is not anywhere near my skillset, but the Selenium codebase is. If appreciated, I would like to contribute a fix such that
org.openqa.selenium.remote.service.DriverService#stopis changed such that in theGeckoDriverServicea "hook" is called to shut down geckodriver and Firefox by sending a DELETE to the session.Note that the `` already contains related code:
However, geckodriver does not have such a
/shutdownendpoint. An approach could be to factor this code out into a separate method and to override it inGeckoDriverServiceby sending an HTTP DELETE request to the/{session-id}endpoint.DELETE on stop as default behaviour?
Note that I don't really know why this isn't default behaviour.
org.openqa.selenium.grid.node.ProtocolConvertingSessionalready always forwards DELETE requests. But maybe there are other implementations that I'm not aware of though.