Repository navigation
Unix domain path too long when using pipe as transport for macOS on Apple Silicon #1346
Description
VS Code Java extension is experimenting with using pipes as the transport mechanism between the language client and the Java language server. However, the automatically generated pipe paths for macOS on Silicon (such as /var/folders/c4/f8v01p_s2sn9_hrx6y18dlxr0000gq/T/vscode-b4e4949e2fde772119c33ebd3ad375f0e8b742abf2.sock) are too long and exceed the OS domain socket limit. See the generateRandomPipeName function in language client, it uses 21 random bytes (which is converted to 42 characters) as suffix, can we reduce the random suffix to a lower value?
vscode-languageserver-node/jsonrpc/src/node/main.ts
Lines 175 to 192 in d859bb1
| export function generateRandomPipeName(): string { | |
| const randomSuffix = randomBytes(21).toString('hex'); | |
| if (process.platform === 'win32') { | |
| return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`; | |
| } | |
| let result: string; | |
| if (XDG_RUNTIME_DIR) { | |
| result = path.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`); | |
| } else { | |
| result = path.join(os.tmpdir(), `vscode-${randomSuffix}.sock`); | |
| } | |
| const limit = safeIpcPathLengths.get(process.platform); | |
| if (limit !== undefined && result.length > limit) { | |
| RIL().console.warn(`WARNING: IPC handle "${result}" is longer than ${limit} characters.`); | |
| } | |
| return result; |
See the original issues on Java extension for more context information.
- Not Starting Up Properly Probably Due to Unix Domain Socket Length Limitations redhat-developer/vscode-java#3371
- [Blocker] With latest pre-release versions LS doesn't start-up on apple aarch64 platform eclipse-jdtls/eclipse.jdt.ls#2932
// Dirk Bäumer (@dbaeumer) WDYT?
Activity
testforstephen commentedon Oct 31, 2023
The tmp directory
/var/folders/…(generated byos.tmpdir()) is actually a symlink to/private/var/folders/…, which has a longer path. This causes the pipe path to exceed the 103 characters limit on macOS. We need to find a way to shorten the pipe path for macOS.dbaeumer commentedon Oct 31, 2023
I recoded the code a little that generates the pipe name.
Jinbo Wang (@testforstephen) could you patch the JS code in the lib folder to see if this works for you under Mac
testforstephen commentedon Nov 1, 2023
Dirk Bäumer (@dbaeumer) thanks for the quick patch.
I can confirm the patch works well on macOS M2 machine, which generates a new pipe path in the format of
/private/var/folders/j9/2657q9qj5mgc31phjzjz_g8r0000gq/T/lsp-9b5c0dd5f8a89159ce06a26866a2c94c.sock.I also tried it in Windows 10 and WSL (ubuntu 20), the new pipe format works.
dbaeumer commentedon Nov 1, 2023
I will prepare a next release so that you can try to publish something.
karthiknadig commentedon Nov 3, 2023
related: #1351
dbaeumer commentedon Nov 6, 2023
I released 9.0.2-next.1 which contains the new code to compute the pipe name