                 case .failure(let error):
                     log.error(error)
                     completion(nil)
+                    self?.isRequesting = false
                 }
             }
     }

                case .success(let html):
                    if let rank = self?.extractRank(from: html, liveId: liveId) {
                        completion(rank)
                    } else {
                        // Continue fetching further page recursively.
                        self?.queryRank(
                            liveId: liveId,
                            page: page + 1,


private extension RankingManager {
    func queryRank(liveId: String, page: Int, completion: @escaping (Int?) -> Void) {
        guard !isRequesting else {
            // Previous request is still in progress, reject the query.
            completion(nil)
            return
        }
        guard let urlString = rankingUrlString(for: page),
              let url = URL(string: urlString)
        else {
            // Query reached to max page, quit to further requesting.
            completion(nil)
            isRequesting = false
            return
        }
        isRequesting = true
        var request = URLRequest(url: url)
        request.headers = [commonUserAgentKey: commonUserAgentValue]
        AF.request(request)
