The call stack
Why one customer's support thread is a blank page.
Start the lessontranscript
One customer's page went blank. The agent's fix froze it. Both come down to the call stack.
I open my support thread, and the page goes blank. Only yours? The console shows one line: RangeError, maximum call stack size exceeded.
This is the code that draws a thread. I wrote it. It draws a comment, then calls itself for each reply. Let me run it on a normal one first. While the deepest reply is being drawn, how many renderReplies calls are still running?
Ana's thread came from an import. Her first message names its own reply as its parent. So c1 draws c2, and c2 draws c1, forever. At about five thousand calls, Chrome stops the script.
Can you fix the crash? Done. I wrapped the loop in try and catch. If it fails, I retry with the same comment. Now my page is stuck. Same input, same calls. My retry never ends. Twenty seconds later, Chrome was still running it.
Remember which comments you have drawn, and skip one you have seen. c2 finds c1 already drawn and returns at once. Every comment draws once, and the stack empties. It loads now. Fix the cycle, not the error.