• Resolved soullax

    (@soullax)


    Hi.

    We’ve been using your plugin for a while and all was working well. I’ve created a new role in Discord and i’m trying to map all Memberpress tiers over to the new role in Discord. However when I do so, the plugin freezes and I get an error in the Dev Console.

    jquery.min.js?ver=3.7.0:2 Uncaught RangeError: Maximum call stack size exceeded at Function.I (jquery.min.js?ver=3.7.0:2:7093) at Function.<anonymous> (jquery-migrate.min.js?ver=3.4.1:2:2898) at e.<computed> [as find] (jquery-migrate.min.js?ver=3.4.1:2:1582) at e.<computed>.find (jquery.min.js?ver=3.7.0:2:21953) at String.<anonymous> (memberpress-discord-admin.min.js?ver=1.0.17:9:46) at Function.each (jquery.min.js?ver=3.7.0:2:3179) at Object.success (memberpress-discord-admin.min.js?ver=1.0.17:7:40) at c (jquery.min.js?ver=3.7.0:2:25266) at Object.fireWith [as resolveWith] (jquery.min.js?ver=3.7.0:2:26015) at l (jquery.min.js?ver=3.7.0:2:77721)

    Loading the page back up afterwards then shows some issues and not all of the existing links before I saved are present anymore. It freezes the web page and it won’t let me remove or add any new connections. The only resolution is to Flush Mappings – but adding back the mappings afterwards causes the same issue…

    I think there’s a bug somewhere in the code…

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Younes

    (@vanbom)

    @soullax
    How many discord roles do you have?
    Discord roles are loaded each time a page is opened to keep them updated

    Thread Starter soullax

    (@soullax)

    We have 29 roles but they load fine in the list. There is a little spinning wheel that appears above the list of roles that keeps spinning but the list populates fine. It feels like it’s the role connections that’s the issue?

    Plugin Contributor Younes

    (@vanbom)

    @soullax

    Yes, as I mentioned in the previous message, when loading the plugin, we retrieve the list of disrod roles, this explains the loading icon that you notice

    Thread Starter soullax

    (@soullax)

    Yes. But the list loads fine when there aren’t any connections set. But the issue happens when I set up connections to my Memberpress tiers. It’s not a problem with loading the roles from Discord.

    Plugin Contributor Younes

    (@vanbom)

    @soullax can you screenshot please

    • This reply was modified 1 year, 2 months ago by Younes.
    Thread Starter soullax

    (@soullax)

    1 When things are working fine (dragging is a bit slow , but still works).

    2 A few connections setup also loads fine.

    3 Adding more connections is slow, but achievable.

    4 Hitting save afterwards apparently “saves” fine, but then when the page reloads… This happens… And there’s an error in the Dev Console.

    Plugin Contributor Younes

    (@vanbom)

    @soullax

    You have a considerable number of discord roles that are causing this issue

    Thread Starter soullax

    (@soullax)

    It wasn’t working even with 14 roles. I don’t think that’s the issue…

    • This reply was modified 1 year, 2 months ago by soullax.
    Thread Starter soullax

    (@soullax)

    Did some debugging myself… Issue was not to do with the number of Discord roles…

    After your code loads all roles from Discord, it then loads and iterates the list of Memberpress Tiers. The code then iterates through the list of relationships of Memberpress Tiers to Discord Roles.

    For each iteration it searches for the role-specific element (from the left hand role list), which it then clones over into the connections list to display it next to the connected Memberpress Tier.

    var preclone = $('*[data-role_id="' + val + '"]').clone();

    This, while logical, causes issues later on if we have more than one Memberpress Tier connected to the same Discord Role. As the code continues to iterate through each defined connections, the value of preclone returns the role-specific element (from the left hand role list), AND ALL other previously created connection elements (from the right hand connection list).

    It looks as though you’ve tried to fix this issue in the past with the below section, but this just hides the elements rather than removing them from the array of retrieved items.

    if(preclone.length>1) {
        preclone.slice(1).hide();
    }

    By the time a few iterations happen, the list of elements in preclone becomes massive as it almost doubles in length for every iteration. For example – just before the stack size error occurs, the array of elements passed to the makeDrag function is pretty big…

    A simple fix… Turn:

    preclone.slice(1).hide();

    to

    preclone = preclone.first();

    on line 67.

    • This reply was modified 1 year, 2 months ago by soullax.
    Thread Starter soullax

    (@soullax)

    This also fixes the page lag too. Please get this fixed and released. Many thanks

    Plugin Contributor Younes

    (@vanbom)

    Hi @soullax

    I wanted to extend my heartfelt thanks for taking the time to share your insightful solution on the Forum support.

    Your contribution is immensely valuable, and I truly appreciate your effort in helping resolve the issue.

    Rest assured, your solution will be incorporated in the upcoming release at the earliest convenience.

    Your dedication to improving our plugin is highly commendable.

    Once again, thank you for your invaluable assistance.

    We’re fortunate to have users like you in our community.

    Thread Starter soullax

    (@soullax)

    A better approach might be to clone after retrieving the element – to improve efficiency even more. However, i’ve not tested this… For example:

    var preclone = $('*[data-role_id="' + val + '"]');
    if(preclone.length>1) {
        preclone = preclone.first();
    }
    preclone = preclone.clone();
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Plugin Freezes when Saving Role Mapping Settings’ is closed to new replies.