Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-v3-0324· DeepSeekHugging Face LMArena Human Preference 140K

r: Maximum call stack size exceeded. at HTMLDocument.<anonymous>…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-medium-2505’s answer.
  1. User

    r: Maximum call stack size exceeded. at HTMLDocument. (bootstrap.5.0.2.bundle.min.js:6:51954) Why this error comes

  2. DeepSeek Assistant

    Understanding the "Maximum call stack size exceeded" Error

    This error occurs when your JavaScript code has too many nested function calls, exceeding the browser's call stack limit. Here's what's happening in your specific case:

    Root Cause

    The error is coming from Bootstrap's bundled JavaScript file (bootstrap.5.0.2.bundle.min.js), specifically in code that runs when the HTML document is being processed.

    Common Reasons for This Error

    1. Infinite recursion: A function that keeps calling itself without a proper exit condition
    2. Event listener issues: An event handler that triggers itself (like a click handler that programmatically clicks the same element)
    3. Large DOM manipulation: Processing a very large DOM tree with recursive functions
    4. Circular dependencies: In module systems where files reference each other

    How to Fix It

    1. Check for recursive functions: Look for any functions that call themselves and ensure they have proper termination conditions

    2. Review event listeners:

      • Make sure you're not adding the same event listener multiple times
      • Check for event handlers that might trigger the same event they're handling
    3. Inspect DOM-related code:

      • If you're using Bootstrap's JavaScript components, check your initialization code
      • Look for any custom code that might be processing the DOM in a recursive way
    4. Update Bootstrap: Since you're using Bootstrap 5.0.2, try updating to the latest version (currently 5.3.x) as this might be a known issue that was fixed

    5. Debugging steps:

      • Try loading the non-minified version of Bootstrap to get better error messages
      • Check your browser's developer tools to see the full call stack when the error occurs
      • Temporarily remove custom JavaScript to isolate the problem

    Without seeing your specific code, these are the most likely causes and solutions for this type of error with Bootstrap.

  3. User

    This is my code when I click on Excel assassment-add target and error comes

  4. DeepSeek Assistant

    The error occurs because you're trying to open an offcanvas (#assassment-add) while simultaneously closing a modal (#formSelectionModal) using data-bs-dismiss="modal". This can sometimes cause conflicts in Bootstrap's JavaScript.

    Solution Options:

    1. Delay the offcanvas opening (recommended)

    <button data-bs-toggle="offcanvas" data-bs-target="#assassment-add" 
            aria-controls="offcanvasRight" class="btn btn-primary" type="button" 
            data-bs-dismiss="modal" onclick="setTimeout(() => bootstrap.Offcanvas.getOrCreateInstance('#assassment-add').show(), 200)">
        Excel
    </button>
    

    2. Use JavaScript to handle the transition

    document.querySelector('[data-bs-target="#assassment-add"]').addEventListener('click', function(e) {
        e.preventDefault();
        var modal = bootstrap.Modal.getInstance(document.getElementById('formSelectionModal'));
        modal.hide();
        
        modal._element.addEventListener('hidden.bs.modal', function() {
            var offcanvas = new bootstrap.Offcanvas(document.getElementById('assassment-add'));
            offcanvas.show();
        });
    });
    

    3. Alternative HTML-only approach

    <button class="btn btn-primary" type="button" 
            onclick="document.getElementById('formSelectionModal').querySelector('[data-bs-dismiss=modal]').click(); setTimeout(() => new bootstrap.Offcanvas(document.getElementById('assassment-add')).show(), 100)">
        Excel
    </button>
    

    Why this happens:

    1. Bootstrap's modal and offcanvas components both manipulate the body's classes and scroll behavior
    2. When you try to close a modal and open an offcanvas simultaneously, the event chain can get interrupted
    3. The call stack exceeds because these operations trigger multiple nested events

    Best Practice:

    The cleanest solution is to use a small delay (option 1 or 3) to let the modal close completely before opening the offcanvas. A 100-200ms delay is usually enough and won't be noticeable to users.

    If you need to implement this for both buttons, you can create a reusable function:

    function transitionToOffcanvas(offcanvasId) {
        const modal = bootstrap.Modal.getInstance(document.getElementById('formSelectionModal'));
        modal.hide();
        modal._element.addEventListener('hidden.bs.modal', function() {
            new bootstrap.Offcanvas(document.getElementById(offcanvasId)).show();
        });
    }
    

    Then update your buttons:

    <button class="btn btn-primary" type="button" 
            onclick="transitionToOffcanvas('assassment-add')">
        Excel
    </button>
    <button class="btn btn-secondary" type="button" 
            onclick="transitionToOffcanvas('compentency-add')">
        Competency
    </button>
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.