message: Handle pipe errors from cmake-server (Don't deadlock)
diff: @@ -366,6 +366,7 @@ export interface ClientInit {
  interface ClientInitPrivate extends ClientInit {
  onHello: (m: HelloMessage) => Promise<void>;
  onCrash: (retc: number, signal: string) => Promise<void>;
  + onPipeError(e: Error): Promise<void>;
  tmpdir: string;
  }
  @@ -530,7 +531,9 @@ export class CMakeServerClient {
  codemodel(params?: CodeModelParams): Promise<CodeModelContent> { return this.sendRequest('codemodel', params); }
  - private _onErrorData(data: Uint8Array) { log.error(`[cmake-server] ${data.toString()}`); }
  + private _onErrorData(data: Uint8Array) {
  + log.error(`Unexpected stderr/stdout data from CMake Server process: ${data.toString()}`);
  + }
  public async shutdown() {
  this._pipe.end();
  @@ -543,7 +546,7 @@ export class CMakeServerClient {
  if (process.platform === 'win32') {
  pipe_file = '\\\\?\\pipe\\' + pipe_file;
  } else {
  - pipe_file = path.join(params.binaryDir, `.cmserver.${process.pid}`);
  + pipe_file = `/tmp/cmake-server-${Math.random()}`;
  }
  this._pipeFilePath = pipe_file;
  const final_env = util.mergeEnvironment(process.env as proc.EnvironmentVariables, params.environment);
  @@ -555,12 +558,14 @@ export class CMakeServerClient {
  child.stdout.on('data', this._onErrorData.bind(this));
  child.stderr.on('data', this._onErrorData.bind(this));
  setTimeout(() => {
  - const end_promise = new Promise<void>(resolve => {
  + const end_promise = new Promise<void>((resolve, reject) => {
  const pipe = this._pipe = net.createConnection(pipe_file);
  pipe.on('data', this._onMoreData.bind(this));
  - pipe.on('error', () => {
  + pipe.on('error', e => {
  debugger;
  pipe.end();
  + params.onPipeError(e);
  + reject(e);
  });
  pipe.on('end', () => {
  pipe.end();
  @@ -601,6 +606,11 @@ export class CMakeServerClient {
  reject(new StartupError(retc));
  }
  },
  + onPipeError: async e => {
  + if (!resolved) {
  + reject(e);
  + }
  + },
  onHello: async (msg: HelloMessage) => {
  // We've gotten the hello message. We need to commense handshake
  try {
  