Skip to content

Commit

Permalink
Add warning about long generated IPC paths, fix #86382
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Apr 7, 2020
1 parent d78f341 commit 19c169a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/vs/platform/environment/node/environmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as resources from 'vs/base/common/resources';
import { memoize } from 'vs/base/common/decorators';
import product from 'vs/platform/product/common/product';
import { toLocalISOString } from 'vs/base/common/date';
import { isWindows, isLinux } from 'vs/base/common/platform';
import { isWindows, isLinux, Platform, platform } from 'vs/base/common/platform';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { URI } from 'vs/base/common/uri';

Expand Down Expand Up @@ -265,15 +265,31 @@ export class EnvironmentService implements INativeEnvironmentService {
// Related to https://github.com/Microsoft/vscode/issues/30624
export const xdgRuntimeDir = process.env['XDG_RUNTIME_DIR'];

const safeIpcPathLengths: { [platform: number]: number } = {
[Platform.Linux]: 107,
[Platform.Mac]: 103
};

function getNixIPCHandle(userDataPath: string, type: string): string {
const vscodePortable = process.env['VSCODE_PORTABLE'];

let result: string;
if (xdgRuntimeDir && !vscodePortable) {
const scope = crypto.createHash('md5').update(userDataPath).digest('hex').substr(0, 8);
return path.join(xdgRuntimeDir, `vscode-${scope}-${product.version}-${type}.sock`);
result = path.join(xdgRuntimeDir, `vscode-${scope}-${product.version}-${type}.sock`);
} else {
result = path.join(userDataPath, `${product.version}-${type}.sock`);
}

const limit = safeIpcPathLengths[platform];
if (typeof limit === 'number') {
if (result.length >= limit) {
// https://nodejs.org/api/net.html#net_identifying_paths_for_ipc_connections
console.warn(`WARNING: IPC handle "${result}" is longer than ${limit} chars, try a shorter --user-data-dir`);
}
}

return path.join(userDataPath, `${product.version}-${type}.sock`);
return result;
}

function getWin32IPCHandle(userDataPath: string, type: string): string {
Expand Down

0 comments on commit 19c169a

Please sign in to comment.