message: refactor: timeout logic
diff: @@ -176,22 +176,26 @@ export class ProcessHandler {
  this.state = State.stopped;
  - return new Promise((resolve) => {
  - let resolved = false;
  - this.forkedProcess.once('exit', () => {
  + const forkedProcess = this.forkedProcess;
  this.forkedProcess = null;
  - resolved = true;
  +
  + return new Promise((resolve) => {
  +
  + const timer = setTimeout(() => {
  + forkedProcess.kill('SIGKILL');
  + setTimeout(resolve, 2000);
  + }, SHUTDOWN_TIMEOUT);
  +
  + forkedProcess.once('exit', () => {
  + clearTimeout(timer);
  resolve();
  });
  - setTimeout(() => {
  - if(!resolved) {
  - this.forkedProcess.kill('SIGKILL');
  - }
  - resolve();
  - }, SHUTDOWN_TIMEOUT);
  - this.forkedProcess.kill('SIGTERM');
  +
  + forkedProcess.kill('SIGTERM');
  +
  });
  +
  }
  /**
  