Prevent page unresponsive error/ popup

So I wrote a program to calculate combinations but takes a longer time to do so: https://codepen.io/Mike-was-here123/pen/MLLprL

On line 4 of Javascript, it will set the infinite loop timeout to one hour. This is so the program will not stop after a couple of seconds thinking the program is infinitely looped and it works.

However, I am having another issue. After 10 - 20 seconds the program stop and the webpage will come up with an unresponsive popup error. How can I go about preventing or controlling this in JavaScript?

I don’t understand the question. The code is working fine when I tried.

If you do a large enough string with a large enough combination and therefore a long time to calculate the webpage will get a unresponsive warning and stop working.

Example:

image

Wow, haven’t seen THAT ugly graphic in a long while. Almost like an easter egg nowadays.

1 Like

If your process is going to be a long-running background process, you may want to look into something like Web Workers.

1 Like

Is their anyway to trick the webpage into thinking it is not unresponsive?

It is probably a self defense mechanism to stop the client’s PC from locking up.
Try to write the code more robust to prevent the memory crash.

2 Likes