Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private String generateRandomPipeName() {
randomLength = Math.min(limit - tmpDir.length() - fixedLength, randomLength);
}
if (randomLength < 16) {
throw new NamedPipeConnectionException("Unable to generate a random pipe name with character length less than 16");
tmpDir = "/tmp/";
JavaLanguageServerPlugin.logInfo("length of random pipe name too long, using /tmp/ as tmpDir");
}

String randomSuffix = generateRandomHex(randomLength/2);
Expand Down
7 changes: 5 additions & 2 deletions extension/src/util/generateRandomPipeName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ function generateRandomPipeName(): string {

let randomLength = 32;
const fixedLength = ".sock".length;
const tmpDir: string = fs.realpathSync(XDG_RUNTIME_DIR ?? os.tmpdir());
let tmpDir: string = fs.realpathSync(XDG_RUNTIME_DIR ?? os.tmpdir());
const limit = safeIpcPathLengths.get(process.platform);
if (limit !== undefined) {
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
}
if (randomLength < 16) {
throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
sendInfo("", {
kind: "tempDirTooLongWhenGenerateRandomPipeName",
});
tmpDir = "/tmp/";
}

const randomSuffix = randomBytes(Math.floor(randomLength / 2)).toString("hex");
Expand Down