[4.0.0-alpha5] Selenium creates never ending Thread
π Bug Report
After simply starting and quiting the webdriver, the browser started and quitted normally. But just the program never ends after running all the steps. I found that there is dead thread (AsyncHttpClient) left running.
Detail steps
My simple program:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SeleniumTestChromiumEdge {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
System.out.println("Before quit");
driver.quit();
System.out.println("After quit");
}
}
Callstack before WebDriver driver = new xxxxDriver();:

Callstack after WebDriver driver = new xxxxDriver();:

Callstack after driver.quit();:

After program ends:

Console output: (e.g. Firefox driver)
1585930423908 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\TSZCHU~1\\AppData\\Local\\Temp\\rust_mozprofilezIRvii"
1585930424530 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid extension permission: networkStatus
1585930425313 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid extension permission: mozillaAddons
1585930425314 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid extension permission: telemetry
1585930425314 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid extension permission: resource://pdf.js/
1585930425314 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid extension permission: about:reader*
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find
profile directory.
1585930428409 Marionette INFO Listening on port 49442
1585930428628 Marionette WARN TLS certificate errors will be ignored for this session
4ζ 04, 2020 12:13:48 δΈε org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Before quit
After quit
I have tried for ChromeDriver, FirefoxDriver and EdgeDriver, in VS Code and Eclipse. Still the same problem.
This problem does not exist when running the same code with v3.14159.
Compare to the callstack from v3.14159 (after starting the driver):

Expected behavior
The program should ends.
Environment
OS: Windows 10 Browser:
- Chrome Version 80.0.3987.163 (Official Build) (64-bit)
- Firefox 74.0 (64-bit)
- Microsoft Edge 80.0.361.109 (Official build) (64-bit) Browser Driver version: All in respective versions Language Bindings version: 4.0.0-alpha-5 IDE: Tried in VS Code and Eclipse
Yes, there are long-running threads, but they should not prevent stopping the VM.
Can you please get a complete thread dump and attach it here for investigation?
thread dump thread_dump.txt
Hi, I have a use case for Selenium where I can't just use System.exit to close the JVM (like in JUnit), making this a significant issue for me. I've noticed this problem in all the 4.0.0-alpha's I've tried, including my last test using :
- Chrome Version 85.0.4183.59 (Official Build) beta (64-bit) (Windows)
- ChromeDriver 85.0.4183.38
- Eclipse IDE (ran in debug mode to confirm the non-daemon threads)
- Language Bindings version (Java) 4.0.0-alpha-6
In my test I instantiated the driver using the ChromeDriverService, but output was identical to that described above. This issue has been raised before : https://github.com/SeleniumHQ/selenium/issues/8258
I am experiencing this never ending thread with Chromium edge and Selenium 4 alpha-4 and higher. Is there any way to gracefully close out a test besides killing the java processes?
@Mdillon123 I believe Add shutdown hook to close AsyncHttpClient. #8763 has fixed the issue, at least in Chrome when I tested using alpha-7. It also allowed me to run the same Selenium script concurrently on 4 threads. Above that failures occurred with an interrupted sleep exception inside FluentWait, but that won't have anything to do with this problem.
Closed by mistake, reopening.
Can you please retest in Selenium 4.0-beta-1 (released today) if the issue is still actual.
Seems beta-1 also had the issue, which was fixed by https://github.com/SeleniumHQ/selenium/commit/a5d5af2d8f0db1605ef8d76d4b91901780418d44. It will be included in beta-2.