Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script V8 assignment to null cancels debugging

A variable assignment to null causes debugging to cancel execution at that line. Here is a test script that reproduces the problem:

function myFunction() {
  var a = "Hallo";
  Logger.log("a=" + a);
  var b = null;
  Logger.log("b=" + b);
}

When debugging this script execution is cancelled on line "var b = null;". Log output is:

Mar 11, 2020, 8:52:49 PM    Info    a=Hallo
Mar 11, 2020, 8:52:54 PM    Info    Execution cancelled.

The result is the same when stepping over the line and running past the line in debug mode. However, in the latter case a red error message flashes for a moment at the top of the screen that says: "We're sorry, a server error occurred. Please wait a bit and try again."... waiting and retrying makes no difference. [Tried it again today after Jeff's comment below and was only able to recreate it by stepping over the assignment line in debug mode]

When running the script normally (not in debug) it completes successfully.

like image 260
Tach Avatar asked Mar 11 '20 19:03

Tach


1 Answers

I found temporary workaround:

Temporally (just for debugging) remove var for variable that takes null value.

Be careful: variable without var becomes global - so you can accidentally change value of the global variable with the same name.

But without the var you will not be able to see your variable in the debugger. So another workaround is to test your variable using if statement to see the value in the debugger:

change:

  var b = null;

temporally (just for debugging) to:

  b = null;
  if (b==null){
    var b0='null';
  } else {
    var b0=b;
  }

and observe b0 variable in the debugger

like image 116
Silverbald Avatar answered Sep 27 '22 18:09

Silverbald