React-meteor-data after update to version 2.5.0 subscription is not cleaned up

Hello all,

I encountered this issue after update to version 2.5.0 of the react-meteor-data package. It very easy to reproduce. I did so far the following in my code. I use the useTracker method to trigger a subscription as soon as any depth changes. In the mean time my depth contain limit and skip values. I realize a pagination with this. So i always renew the subscription and until version 2.4.0 it worked like a charm. Since version 2.5.0 I see in the chrome meteor plugin that the subscription is never cleaned up. I creates a new subscription with a new ID on each change of skip and limit, but never clean up the subscription. And before I always found my data with the skip value of 0. Always the part of the documents I want I found in the useTracker method when calling the find().fetch(). I enclose here my code example and as I said until version 2.40 it worked fine. according to the documentation of useTracker() its written that this will be cleaned up automatically as soon as any depth is changing or the component is unmounted. But I had no luck with the new version. I tried also version 2.6.1 (latest). Same thing happen here. Maybe someone can help me with this issue and give me a hint if there was a drastic change in the useTracker() method.

Thanks in advance for any help.

Daniel

Example Code:

const useOrdersSubscription = () => useTracker(() => {

        if (Meteor.isDevelopment) {
            console.log("SUBSCRIPTION ORDERS")
        }

        var getCounterReady = false;
        const subscription = Meteor.subscribe("hvzOrders", { companyAccountId: user.profile.companyAccountId }, sortQuery, limit, skip, searchValueHvzOrders, status, filterHvzOrders);
        Meteor.call("getHvzOrdersCountByCompanyAccount", { companyAccountId: user.profile.companyAccountId }, sortQuery, 0, 0, searchValueHvzOrders, status, filterHvzOrders, (err, res) => {

            getCounterReady = true;
            setOrdersCount(res);

        });
        return !subscription.ready() || getCounterReady === true;
    }, [limit, skip,  JSON.stringify(sortQuery), JSON.stringify(searchValueHvzOrders), JSON.stringify(filterHvzOrders), JSON.stringify(sortDirection)])`


const useOrders = () => useTracker(() => {

        if (Meteor.isDevelopment) {
            console.log("TRACKER USE ORDERS")
        }

        var query = {};


        query.companyAccountId = user.profile.companyAccountId;

        if (status) {
            query.Status = { $eq: status }
        }

        if (filterHvzOrders) {
            if (filterHvzOrders.IsDeleted) {
                if (filterHvzOrders.IsDeleted.length > 0) {

                } else {
                    query.IsDeleted = false;
                }
            } else {
                query.IsDeleted = false;
            }



            if (filterHvzOrders.IsArchived) {
                if (filterHvzOrders.IsArchived.length > 0) {

                } else {
                    query.IsArchived = false;
                }
            } else {
                query.IsArchived = false;
            }
        }
       

        if (Object.keys(filterHvzOrders).length > 0) {
            let filterQuery = [];
            Object.entries(filterHvzOrders).forEach(([key, value]) => {
                // console.log(`${key} ${value}`); // "a 5", "b 7", "c 9"
                let filterElement = key;
                let filterObj = {};
                let regexFilterValue = "";

                if (typeof value === 'object' && !moment(value, moment.ISO_8601, true).isValid()) {
                    // console.log("Value Is Object")
                    let parentKey = key;
                    if (Array.isArray(value)) {

                        //     console.log("FOUND VALUE ARRAY");
                        //     console.log(value)
                        if (value.length > 0) {
                            query[parentKey] = { $in: value };
                        }


                    } else {
                        if (value) {
                            Object.entries(value).forEach(([innerKey, innerValue]) => {

                                filterElement = parentKey + "." + innerKey;
                                if (moment(innerValue, moment.ISO_8601, true).isValid()) {
                                    //item is a date value
                                    filterElement = parentKey + "." + innerKey;


                                    if (key === "StartDate") {
                                        regexFilterValue = { $gte: innerValue }
                                    } else if (key === "EndDate") {
                                        regexFilterValue = { $lte: innerValue }
                                    } else {
                                        regexFilterValue = innerValue;
                                    }
                                } else if (typeof innerValue === 'boolean') {
                                    regexFilterValue = innerValue;

                                } else if (Array.isArray(innerValue)) {
                                    if (innerValue.length > 0) {
                                        query[filterElement] = { $in: innerValue };
                                    }
                                }
                                else {
                                    regexFilterValue = new RegExp("\\b" + innerValue, 'i');
                                }

                            });
                        }


                    }
                } else if (typeof value === 'boolean') {

                    regexFilterValue = { $eq: value };

                } else {

                    if (moment(value, moment.ISO_8601, true).isValid() || typeof value === 'boolean') {
                        //item is a date value

                        if (key === "StartDate") {
                            regexFilterValue = { $gte: value }
                        } else if (key === "EndDate") {
                            regexFilterValue = { $lte: value }
                        } else {
                            regexFilterValue = value;
                        }
                    } else {
                        regexFilterValue = new RegExp("\\b" + value, 'i');
                    }
                }



                if (regexFilterValue) {
                    if (Array.isArray(regexFilterValue)) {

                        if (value.length > 0) {
                            filterObj[filterElement] = regexFilterValue;
                            filterQuery.push(filterObj);
                        }
                    } else {
                        filterObj[filterElement] = regexFilterValue;
                        filterQuery.push(filterObj);
                    }

                }


            });
            if (filterQuery.length > 0) {
                query.$and = filterQuery;
            }
        }

        if (searchValueHvzOrders !== "") {
            let searchQuery = [];
            let split = searchValueHvzOrders.match(/\w+/g);

            if (split === null) {


            } else {
                let regex = new RegExp("\\b" + searchValueHvzOrders, 'i');

                if (HvzOrders.schema._schemaKeys.length > 0) {
                    HvzOrders.schema._schemaKeys.map((item, index) => {

                        let tmpObj = {};

                        if(item.endsWith(".$")){
                            var newItem = item.replace(".$", "");
                            tmpObj[newItem] = { $in: [regex] };
                          }else{
                            tmpObj[item] = regex;
                          }


                       // tmpObj[item] = regex;

                        searchQuery.push(tmpObj)

                    }
                    )
                }
                query.$or = searchQuery;
            }
        }

        if (Meteor.isDevelopment) {
            console.log(HvzOrders.find(query, { sort: sortQuery, limit: limit, skip: 0 }).fetch());
        }

        return HvzOrders.find(query, { sort: sortQuery, limit: limit, skip: 0 }).fetch();
    }, [limit, skip, JSON.stringify(sortQuery), JSON.stringify(searchValueHvzOrders), JSON.stringify(filterHvzOrders), JSON.stringify(sortDirection)])