   defp sync_connect(state) do
     case Utils.connect(state) do
       {:ok, state} ->
-        state = start_receiver_and_hand_socket(state)
+        {:ok, timeout_store} = TimeoutStore.start_link()
+        receiver = start_receiver_and_hand_socket(state.socket, timeout_store)
+        state = %{state | timeout_store: timeout_store, receiver: receiver}
         {:ok, state}
       {:error, reason} ->
         {:stop, reason}

    # the receiver process will not leak (when we spawn a new one when
    # reconnecting) because the old one died right after notifying us. We should
    # be ok.
    :ok = TimeoutStore.add(state.timeout_store, request_id)
    {:reply, :ok, state}
  end

  defp handle_msg_from_receiver({:tcp_error, socket, reason}, %{socket: socket} = state) do
    {:disconnect, {:error, reason}, state}
  end

  defp calc_next_backoff(current_backoff, backoff_max) do
    next_exponential_backoff = round(current_backoff * @backoff_exponent)

    if backoff_max == :infinity do
      next_exponential_backoff
    else
      min(next_exponential_backoff, backoff_max)
    end
  end
end
