Bug Description
When running Java unit tests via Test Runner for Java, the UI stays stuck at:
Resolving launch configuration...
Root Cause
VS Code Test Runner for Java 0.44.0 creates a local socket server before launching tests. It uses get-port to pre-select a port, then closes the probe socket and rebinds to the same port on
127.0.0.1. In WSL/Windows port environments, this "pre-select then rebind" pattern causes massive EADDRINUSE failures.
Evidence from VS Code extension log:
Error: listen EADDRINUSE: address already in use 127.0.0.1:46129
Error: listen EADDRINUSE: address already in use 127.0.0.1:46423
Error: listen EADDRINUSE: address already in use 127.0.0.1:46333
Error: listen EADDRINUSE: address already in use 127.0.0.1:46049
Error: listen EADDRINUSE: address already in use 127.0.0.1:45865
Reproduction
The problematic pattern in the extension:
const port = await getPort(); // Step 1: reserve a port
server.listen(port, "127.0.0.1", callback); // Step 2: rebind to same port
In the affected environment, ~96 out of 100 such attempts fail.
Suggested Fix
Replace the two-step port selection with direct port allocation:
server.listen(0, "127.0.0.1", callback); // OS auto-assigns a free port
This approach achieves 0 failures in the same environment.
Environment
- OS: Windows + WSL
- VS Code Test Runner for Java: 0.44.0
- Multiple JDKs installed (Java 8, 21, 25)
Bug Description
When running Java unit tests via Test Runner for Java, the UI stays stuck at:
Resolving launch configuration...
Root Cause
VS Code Test Runner for Java 0.44.0 creates a local socket server before launching tests. It uses
get-portto pre-select a port, then closes the probe socket and rebinds to the same port on127.0.0.1. In WSL/Windows port environments, this "pre-select then rebind" pattern causes massiveEADDRINUSEfailures.Evidence from VS Code extension log:
Error: listen EADDRINUSE: address already in use 127.0.0.1:46129
Error: listen EADDRINUSE: address already in use 127.0.0.1:46423
Error: listen EADDRINUSE: address already in use 127.0.0.1:46333
Error: listen EADDRINUSE: address already in use 127.0.0.1:46049
Error: listen EADDRINUSE: address already in use 127.0.0.1:45865
Reproduction
The problematic pattern in the extension: