Apps脚本调试器不会让我查看对象(包括数组和块作用域)中的值 [英] Apps Script debugger won't let me look at values in objects (including arrays and block scopes)

查看:77
本文介绍了Apps脚本调试器不会让我查看对象(包括数组和块作用域)中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试Apps脚本项目,并且在过去的2-3天中,调试器不允许我查看在范围级别定义的变量。

I'm trying to debug an Apps Script project, and for the past 2–3 days, the debugger hasn't let me look at variables defined at the scope level.

例如,我正在尝试调试此代码。

For example, I was trying to debug this code.

/**
 * Deletes all rows in a sheet, excluding header rows. Just calling sheet.deleteRows() 
 * for a massive range of rows will throw out an error.
 * @private
 * 
 * @param {Sheet} sheet 
 * @param {number = 0} numHeaderRows 
 * @param {number = 500} deletionSize - The number of rows to delete at a time
 */
function deleteAllNonHeaderRows_(sheet, numHeaderRows = 0, deletionSize = 500) {
  const startingNumberOfRows = sheet.getMaxRows();
  for (let numRows = startingNumberOfRows; numRows > numHeaderRows; numRows -= deletionSize) {
    if (numRows < deletionSize) {
      const deletionArgs = [numHeaderRows + 1, sheet.getLastRow() - numHeaderRows]
      sheet.deleteRows(...deletionArgs);
    } else {
      sheet.deleteRows(numRows - deletionSize, deletionSize);
    }
  }
}

通常这是一个快速的过程,但是由于无法查看要传递给 sheet.deleteRows()的参数的值,因此花了一些时间告诉我应该使用 sheet.getMaxRows()而不是 sheet.getLastRow()。使用调试器会弹出一个列出所有范围的菜单,但是尝试扩展块范围并没有任何作用。经过一番修补后,我发现此问题扩展到了作为对象实现的所有内容,因此也包括了数组。扩展本地范围是可行的,但是如果其中存在任何对象,我将无法扩展它。

It normally would have been a quick process, but since I couldn't look at the value of the arguments I was trying to pass into sheet.deleteRows(), it took me a moment to tell that I should have used sheet.getMaxRows() instead of sheet.getLastRow(). Using the debugger brings up a menu that lists all the scopes, but trying to expand the block scopes doesn't do anything. After some tinkering, I found that this problem extends to everything implemented as an object, so arrays are included, too. Expanding local scopes works, but if any kind of object is in there, I can't expand it.

我不确定是什么原因导致了此问题。我当时在Edge中进行编码,但是切换到Chrome并没有任何改变(可能是因为它们都是基于Chromium的)。我还尝试禁用所有广告拦截器和隐私保护器。查找其他人最近也没有发表过的问题。有什么可以做的吗?我还偶尔会收到一些错误消息,例如无法连接到服务器。但是脚本本身运行良好,无论是在容器绑定文件中运行还是在编辑器本身中运行。

I'm not sure what could be causing this problem. I was coding in Edge, but switching to Chrome didn't change anything (likely because they're both Chromium-based). I've also tried disabling all my ad blockers and privacy protectors. Looking up issues other people have had didn't turn up any recent posts, either. Is there anything that can be done? I also keep occasionally getting error messages saying something like "Could not connect to server". But the scripts themselves run fine, whether they're run in the container-bound file or the editor itself.

推荐答案

编辑:

(截至2020年9月1日)

(as of September 1, 2020)

原始答案:

(截至7月2020年3月23日)

(as of July 23, 2020)

使用调试器将导致UI响应无响应(报告有所不同),服务器响应 409 ,断点挂起执行。如果您遇到类似的行为,请在下面的问题加注星标。

Using the debugger results in non-responsive UI (reports vary), server responses of 409, breakpoints hang execution. Star the issue linked to below if you are experiencing similar behavior.

链接到Google的IssueTracker中的问题:调试模式在V8中不响应

这篇关于Apps脚本调试器不会让我查看对象(包括数组和块作用域)中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆