3

I have noticed that GAS's debugger cannot handle breakpoints in callback functions. This simple script works fine if run, but if a breakpoint is set at the line return element, the debugger throws an error This operation is not supported from a callback function. Here is the test function:

function callbackTest() {

  var myArray = [1,2,3];

  var output = myArray.map(function(a){
    return a;
  });

  Logger.log(output);
}

This also fails if a breakpoint is put at the same place:

function callbackTest() {

  var myArray = [1,2,3];
  var output = myArray.map(testFunc);
  Logger.log(output);

}

function testFunc(a) {
    return a;
}

I had a question a few days ago about the GAS debugger, but this doesn't seem (to me) to be related. Please feel free to demonstrate that I am wrong!

Community
  • 1
  • 1
Charlie Patton
  • 435
  • 2
  • 12
  • So what are you asking here? How to debug callbacks? – nnnnnn Sep 19 '15 at 12:31
  • Yes. I'm admittedly a novice, but I haven't found any resources suggesting that there is some special process for debugging non-async callbacks. Am I missing something? – Charlie Patton Sep 19 '15 at 13:30
  • I think you've just hit a limitation in the script editor that you're not going to get around, just throw a load of Logger.log()'s at it. I've noticed that the script editor avoids displaying any functions that need callbacks in the auto-complete. – Andrew Roberts Sep 19 '15 at 20:10
  • That makes sense, but it was surprising to me to see that. Is it common for editors to have such serious limitations like this? Obviously I can work around it, but it really makes debugging a pain. – Charlie Patton Sep 21 '15 at 14:52
  • 3
    This has been reported as [Issue 4662](https://code.google.com/p/google-apps-script-issues/issues/detail?id=4662). Star it, etc. – Mogsdad Sep 22 '15 at 21:06
  • @Mogsdad, if you want to answer the question I'll mark it as accepted. – Charlie Patton Jun 15 '16 at 19:17
  • 2
    Someone beat me to it! There is an answer covering this on another question, so it would be best to just duplicate this one. – Mogsdad Jun 15 '16 at 19:30

0 Answers0