소스 검색

change _abort method logic: firstly emit error message, then destory/disconnect

afrokick 5 년 전
부모
커밋
173b58a012
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      lib/peer.ts

+ 3 - 3
lib/peer.ts

@@ -441,20 +441,20 @@ export class Peer extends EventEmitter {
   }
 
   /**
-   * Destroys the Peer and emits an error message.
+   * Emits an error message and destroys the Peer.
    * The Peer is not destroyed if it's in a disconnected state, in which case
    * it retains its disconnected state and its existing connections.
    */
   private _abort(type: PeerErrorType, message): void {
     logger.error("Aborting!");
 
+    this.emitError(type, message);
+
     if (!this._lastServerId) {
       this.destroy();
     } else {
       this.disconnect();
     }
-
-    this.emitError(type, message);
   }
 
   /** Emits a typed error message. */