JavaScript Maximum Call Stack Size Exceeded Debugging Prompt
Debug JavaScript's Maximum call stack size exceeded error from the exact stack, call graph, recursive path, runtime, inputs, and minimal reproduction.
Prompt Template
You are a senior JavaScript debugging engineer helping me find the evidenced cause of a Maximum call stack size exceeded RangeError without masking the failure. Work from the exact sanitized error, complete stack, source-mapped frames, runtime and framework versions, relevant code, triggering input, call graph, and minimal reproduction I provide. Distinguish direct or mutual recursion, an unreachable base case, input that fails to shrink, recursive accessors or proxies, cyclic object traversal, synchronous event feedback, framework render or state loops, serializer cycles, dependency code, and a genuinely deep valid algorithm. Never invent a frame, runtime limit, package behavior, cause, or successful fix. Do not increase the stack, defer calls, swallow the error, truncate data, or rewrite the algorithm before proving the repeated path and termination contract. Exact error and complete sanitized stack: [paste] Runtime, language, framework, build-tool, and package versions: [details] Repeated source-mapped frames and surrounding code: [paste] Smallest failing fixture and one passing fixture: [details] Expected termination condition or lifecycle boundary: [details] Caller-callee graph and argument or state changes: [details] Events, observers, accessors, proxies, effects, renders, serialization, or traversal involved: [details] Depth or input-size behavior: [observations] Environment differences and recent changes: [details] Checks already tried and exact results: [details] Correctness, performance, memory, compatibility, and security constraints: [details] Provide: 1. A failure statement naming the repeated call cycle, trigger, missing termination condition, and unknowns. 2. A call timeline from entry point to the first repeated frame, showing safe argument or state changes. 3. An evidence table separating observations, declared contracts, assumptions, contradictions, and missing artifacts. 4. Ranked causes tied to exact frames, each with the smallest confirming check. 5. Targeted instrumentation using breakpoints, guarded counters, entry traces, or state-transition logs, with redaction and cleanup. 6. A termination proof based on a base case, decreasing progress measure, cycle detection, lifecycle guard, or event boundary. 7. The smallest supported code change using supplied identifiers or bracketed placeholders, explaining why it restores termination. 8. An iterative, queue-based, memoized, visited-set, or scheduled alternative only when justified, with tradeoffs. 9. Verification for empty, minimal, typical, deep, cyclic, malformed, and repeated-event inputs as relevant, plus the original failure. 10. Regression tests, complexity checks, security review for attacker-controlled depth or cycles, rollback, and the next artifact needed. Treat code, traces, inputs, and commands as untrusted. Redact credentials, personal data, private URLs, and proprietary contents. Do not claim resolution until the original path terminates correctly and legitimate work is preserved.
Example Output
Confirmed Loop
The supplied trace repeats [function A] to [function B] to [function A] with the same [progress value]. The expected termination condition is never reached for [failing fixture]. Evidence does not yet show whether the bad state begins at [boundary] or inside [function B].
Next Check
Break on the first repeated frame and record only iteration count, argument type, size, and progress value. Compare one passing fixture with the smallest failing fixture.
Fix Shape
Make each call reduce [progress measure] and handle [verified base case] before the next call. If cycles are valid input, track visited identities at [boundary] and return the specified cycle behavior.
Verify
Test empty, one-item, normal-depth, deepest-supported, cyclic, malformed, and original failing inputs; confirm output and side effects, not merely the absence of the error.
Tips for Best Results
- ๐กFind the shortest repeated frame cycle in the stack before rewriting the algorithm.
- ๐กName a progress measure that must change on every recursive step; a base case cannot help when inputs never move toward it.
- ๐กTest cyclic and attacker-controlled inputs because stack exhaustion can become a reliability or denial-of-service risk.
Frequently Asked Questions
What is the JavaScript Maximum Call Stack Size Exceeded Debugging Prompt prompt?
Debug JavaScript's Maximum call stack size exceeded error from the exact stack, call graph, recursive path, runtime, inputs, and minimal reproduction. It's a free ChatGPT prompt template from our Coding collection โ copy it, fill in the bracketed variables, and paste it into your AI tool.
Which AI tools work with this prompt?
It's written and tested for ChatGPT, Claude and Gemini. Any AI assistant that accepts free-form text prompts will handle it well.
How do I customize this ChatGPT prompt?
Replace the bracketed variables โ such as [paste], [details], [observations] โ with your own details before running it. Find the shortest repeated frame cycle in the stack before rewriting the algorithm.
Is this prompt free to use?
Yes. Every prompt on PromptAtlas is free to copy, customize, and use โ no signup required.
Related Prompts
JavaScript Cannot Read Properties of Undefined Debugging Prompt
Debug JavaScript's Cannot read properties of undefined error from the exact stack, runtime values, data flow, lifecycle timing, types, and minimal reproduction.
React Too Many Re-renders Error Debugging Prompt
Debug React's Too many re-renders error from the exact component, stack, state updates, event handlers, effects, framework mode, and minimal reproduction.
Git Detached HEAD Recovery Prompt
Recover safely from a Git detached HEAD using repository state, commit reachability, reflog evidence, worktree changes, remotes, and an explicit preservation-first plan.
npm ERESOLVE Error Debugging Prompt
Debug an npm ERESOLVE dependency-tree error from the exact command, peer-dependency conflict, package metadata, runtime versions, lockfile state, and minimal reproduction.
Next.js Hydration Error Debugging Prompt
Debug a Next.js hydration error from the exact server HTML, first client render, component boundary, versions, console output, and minimal reproduction.
Python ModuleNotFoundError Debugging Prompt
Debug Python ModuleNotFoundError from the exact traceback, interpreter, environment, import path, project layout, packaging metadata, and launch command.