redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.05k stars 420 forks source link

Language Support Fails to Start on MacOS: Error: Unable to generate a random pipe name with 7 characters. #3649

Closed bpeCRtMU closed 1 month ago

bpeCRtMU commented 1 month ago

Upon closing and reopening VS Code the Java Language Server fails to start due to the following error:

[Error - 8:04:23 AM] Language Support for Java client: couldn't create connection to server.
Error: Unable to generate a random pipe name with 7 characters.
    at t.generateRandomPipeName (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1136512)
    at /Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1332887
    at async c.createConnection (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1165774)
    at async c.start (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1156291)

Quitting and restarting VS Code does not solve this issue. However, restarting the computer and reopening VS Code works. Meaning the extension works again until you close the window.

Environment
Steps To Reproduce
  1. Open a Java Maven project in VS Code. The language server should start as normal.
  2. Close the VS Code window (don't quit).
  3. Reopen the Java Maven project in VS Code. The language server will fail to start.
Logs

The Java Extension did not produce a log file as it could not start.

VS Code:

Language Support for Java (Syntax Server) client: couldn't create connection to server.

Language Support for Java client: couldn't create connection to server.

[redhat.java]Unable to generate a random pipe name with 7 characters.
$onExtensionRuntimeError @ mainThreadExtensionService.ts:81

Error: Unable to generate a random pipe name with 7 characters.
    at t.generateRandomPipeName (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1136512)
    at vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1332887
    at async c.createConnection (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1165774)
    at async c.start (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1156291)

[Extension Host] rejected promise not handled within 1 second: Error: Unable to generate a random pipe name with 7 characters.

[Extension Host] stack trace: Error: Unable to generate a random pipe name with 7 characters.
    at t.generateRandomPipeName (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1136512)
    at /Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1332887
    at async c.createConnection (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1165774)
    at async c.start (/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1156291)

[redhat.java]Unable to generate a random pipe name with 7 characters.

mainThreadExtensionService.ts:82 Error: Unable to generate a random pipe name with 7 characters.
    at t.generateRandomPipeName (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1136512)
    at vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1332887
    at async c.createConnection (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1165774)
    at async c.start (vscode-file://vscode-app/Users/user/.vscode/extensions/redhat.java-1.30.0-darwin-arm64/dist/extension.js:2:1156291)

[Extension Host] rejected promise not handled within 1 second: Error: ENOENT: no such file or directory, open '/Users/user/Library/Application Support/Code/User/workspaceStorage/6c885cc2ecb35f2626fe6d8ad25fd086/redhat.java/jdt_ws/.metadata/.log'
rgrunber commented 1 month ago

https://github.com/microsoft/vscode-languageserver-node/blob/4fbd145c7a670b1a59fad6f50e3143e4aff92e7f/jsonrpc/src/node/main.ts#L181-L189

Do you have XDG_RUNTIME_DIR defined ? Looks like it might be too long (>70 chars) on MacOS.

aogilvie-indeed commented 1 month ago

I'm getting the same error message.

How can we check for this var? I have not changed my environment in the last few days (although VS Code was updated).

fbricon commented 1 month ago

Until this is fixed, try setting "java.transport" : "stdio" in your vscode settings. See https://github.com/redhat-developer/vscode-java/issues/3634#issuecomment-2096242414 for more details

rgrunber commented 1 month ago

Fred brought up a good point (in discussions), which is that we should be able to restart the language server with stdio if it fails the first time with pipe. The failure happens at https://github.com/redhat-developer/vscode-java/blob/2f5094fb858235120f55952cfb8f6ec987a1a4ac/src/TracingLanguageClient.ts#L32-L36, which is actually well before the initializationFailedHandler gets registered. This complicates relaunching.

Maybe we can improve this.