6

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.

8
  • 1
    There is another V8 issue related to debug on the Issue Tracker: https://issuetracker.google.com/issues/149636786 Commented Mar 11, 2020 at 19:37
  • I couldn't reproduce your error, what steps are you following here? I do Run > Debug function > myFunction Commented Mar 12, 2020 at 11:55
  • 1
    Thank you for the replies. Alan, I had a look at that issue and it might be related but I'm not sure to what extent. Jeff, yes that is how I did it and by stepping from a break point. However, I tried it now again and I couldn't recreate it by just doing Run > Debug function > myFunction. I could only recreate it by setting a break point and stepping over the line doing the null assignment. Commented Mar 13, 2020 at 11:08
  • @Tach You could create a new issue in the issuetracker Commented Mar 13, 2020 at 11:34
  • Related: stackoverflow.com/q/60543633 Commented Mar 13, 2020 at 11:41

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.