Add custom path for vscode-server socket files and named pipe length (#172481)

* Add custom path for vscode-server socket files and named pipe length

* Revert VSCODE_SOCKETS_DIR to XDG_RUNTIME_DIR behavior

* 💄

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@gmail.com>
This commit is contained in:
Mark Zuber 2023-02-22 01:44:19 -08:00 committed by GitHub
parent 3133ffcd12
commit a0bf7f5b13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -759,11 +759,20 @@ export function createStaticIPCHandle(directoryPath: string, type: string, versi
// Mac/Unix: use socket file and prefer
// XDG_RUNTIME_DIR over user data path
// unless portable
// Trim the version and type values for
// the socket to prevent too large
// file names causing issues:
// https://unix.stackexchange.com/questions/367008/why-is-socket-path-length-limited-to-a-hundred-chars
const versionForSocket = version.substr(0, 4);
const typeForSocket = type.substr(0, 6);
const scopeForSocket = scope.substr(0, 8);
let result: string;
if (XDG_RUNTIME_DIR && !process.env['VSCODE_PORTABLE']) {
result = join(XDG_RUNTIME_DIR, `vscode-${scope.substr(0, 8)}-${version}-${type}.sock`);
result = join(XDG_RUNTIME_DIR, `vscode-${scopeForSocket}-${versionForSocket}-${typeForSocket}.sock`);
} else {
result = join(directoryPath, `${version}-${type}.sock`);
result = join(directoryPath, `${versionForSocket}-${typeForSocket}.sock`);
}
// Validate length