Skip to content

VM launch failure doesn't report a useful error #397

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

Closed
karlvr opened this issue Jan 25, 2022 · 1 comment · Fixed by #398
Closed

VM launch failure doesn't report a useful error #397

karlvr opened this issue Jan 25, 2022 · 1 comment · Fixed by #398
Labels

Comments

@karlvr
Copy link
Contributor

karlvr commented Jan 25, 2022

If the VM fails to launch, the error reported to the user is a timeout after 10,000ms rather than an exit status or anything from the stdout or stderr. This makes it very hard to debug launch failures when using the integrated console. If using a terminal, the errors are visible in the terminal.

AdvancedLaunchingConnector doesn't notice that the VM process has terminated and instead has to wait to catch the TransportTimeoutException and then it reports a timeout.

I would love to improve this!

After the timeout we could check if the process has terminated (process.isAlive()) and report that exit status instead of a timeout, and read from the stdout and stderr to construct a better error message and log the stdout / stderr to the console so the user can see what happened. The VMStartException doesn't seem very well suited to our purpose as although it includes the Process, because we .destroy() it we don't have access to the streams. Perhaps we can make our own exception here that can glean more information from the Process.

Ideally instead of waiting for timeout we could observe the process termination early, so the user isn't left hanging for 10s. But it doesn't seem like that's easily supported in the underlying Eclipse code.

I'm going to tinker with this, but I'd love to know if this sounds like the right track for improvement.

@karlvr karlvr changed the title VM launch failure doesn't report an useful error VM launch failure doesn't report a useful error Jan 26, 2022
@karlvr
Copy link
Contributor Author

karlvr commented Mar 12, 2022

I've put together a test project to demonstrate this issue. Please see the attached .zip, it contains the following files:

  • .vscode/launch.json
  • HelloWorld.java

.vscode/launch.json:

{
	"version": "0.2.0",
	"configurations": [
		{
			"type": "java",
			"name": "Launch Current File",
			"request": "launch",
			"mainClass": "HelloWorld",
			"vmArgs": "-wrong",
			"console": "internalConsole"
		}
	]
}

HelloWorld.java:

public class HelloWorld {
	
	public static void main(String[] args) {
		System.out.println("Hello World");
	}

}

Note that it's important that the mainClass actually exists, and then we add a bad vmArgs which causes the java executable to exit immediately. The current implementation of java-debug doesn't detect the exit of the JVM and therefore waits for the 10s timeout.

This is an easy / minimal way to reproduce the error. I originally encountered the error when the JVM exited immediately due to other problems, specifically around modules not being found.

java-debug-test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants