    A connection-check is made after `connection timeout` is reached and
    mailserver-state is changed to error if it is not connected by then"
   [{:keys [db] :as cofx}]
-  (let [{:keys [address] :as mailserver} (fetch-current cofx)
+  (let [{:keys [address]} (fetch-current cofx)
         {:keys [peers-summary]} db
-        added? (registered-peer? peers-summary
-                                 address)]
+        added?       (registered-peer? peers-summary address)
+        gap-request? (executing-gap-request? db)]
     (fx/merge cofx
-              {:db (dissoc db :mailserver/current-request)}
+              {:db (cond-> (dissoc db :mailserver/current-request)
+                     gap-request?
+                     (assoc :mailserver/fetching-gaps-in-progress {}))}
               (if added?
                 (mark-trusted-peer)
                 (add-peer)))))

        (fx/merge cofx
                  {:db (update db :mailserver/current-request dissoc :attempts)}
                  (change-mailserver))
        (if-let [mailserver (get-mailserver-when-ready cofx)]
          (let [{:keys [topics from to cursor limit] :as request} current-request
                web3 (:web3 db)]
            (log/info "mailserver: message request " request-id "expired for mailserver topic" topics "from" from "to" to "cursor" cursor "limit" (decrease-limit))
            {:db (update-in db [:mailserver/current-request :attempts] inc)
             :mailserver/decrease-limit []
             :mailserver/request-messages {:web3 web3
                                           :mailserver mailserver
                                           :request (assoc request :limit (decrease-limit))}})
          {:mailserver/decrease-limit []})))))

(fx/defn initialize-mailserver
  [cofx custom-mailservers]


(fx/defn resend-request
  [{:keys [db] :as cofx} {:keys [request-id]}]
  (let [current-request (:mailserver/current-request db)
        gap-request? (executing-gap-request? db)]
    ;; no inflight request, do nothing
    (when (and current-request
               ;; the request was never successful
