code: function onSocketClose() {
          self.resetAll(errors.SocketClosedError({
              reason: 'remote closed',
              socketRemoteAddr: self.socketRemoteAddr,
              direction: self.direction,
              remoteName: self.remoteName
          }));
  
          if (self.ephemeral) {
              var peer = self.channel.peers.get(self.socketRemoteAddr);
              if (peer) {
                  peer.close(noop);
              }
              self.channel.peers.delete(self.socketRemoteAddr);
          }
      }
docs: TODO: move to method for function optimization