Google script (JS) - maximum recursion depth

What is the maximum recursion depth in Google Apps Scripts? I have a match_recurse function that looks like the following pseudocode:

 function match_recurse(array) { for (i=0, i<3, i++) { var arr2 = array.copy().push(i); if (is_done(arr2)) break; match_recurse(arr2); } } 

(He also returns his results, but I don't want to fan the question.)

Now, since the runtime error, the execution script and the logs were not saved, so I don’t know if my is_done function is is_done . I can do a few cases of the problem on paper and check the depth of the recursion, but I don't know what the maximum should be.

I saw an article on the Internet that mentions that IE has a maximum call stack of 13 if you go through a Window object, but nothing else.

+4
source share
2 answers

This is 1000, as you can see here:

 function recurse(i) { var i = i || 1; try { recurse(i+1); } catch (e) { Logger.log(i); } } 
+2
source

The stack depth value is not documented. Execution of the following code indicates that this value is 1000.

 function getStackDepth(curvalue) { try { curvalue = getStackDepth(curvalue) + 1; } catch(err) { } return curvalue; } function test() { var depth = getStackDepth(2); debugger; } 
+2
source

Source: https://habr.com/ru/post/1440425/


All Articles