I have an interesting desire to know a way to break the recursion before it "freezes" the browser and exhausts all resources.
A banal example is just such a cycle:
while (true) {
console.log('Test');
}
After a few seconds, the browser already becomes unmanageable, and after a few minutes it restarts. You can see this error too:
net::ERR_INSUFFICIENT_RESOURCES
QUESTION: Is it possible to somehow track the execution of recursion in order to stop it at the worst moment and return the browser to working capacity? At the same time, I want this to be a universal method, since the browser resources are different (I mean that exit after the nth iteration or second will not work here).