简体   繁体   English

Apps 脚本调试器不允许我查看对象中的值(包括 arrays 和块作用域)

[英]Apps Script debugger won't let me look at values in objects (including arrays and block scopes)

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.我正在尝试调试应用程序脚本项目,在过去的 2-3 天里,调试器没有让我查看在 scope 级别定义的变量。

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);
    }
  }
}

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() .这通常是一个快速的过程,但由于我无法查看我试图传递给sheet.deleteRows()的 arguments 的值,所以我花了一点时间告诉我应该使用sheet.getMaxRows()而不是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.经过一番修改,我发现这个问题扩展到了所有作为 object 实现的东西,所以 arrays 也包括在内。 Expanding local scopes works, but if any kind of object is in there, I can't expand it.扩展本地范围有效,但如果有任何类型的 object 在那里,我无法扩展它。

图片链接,因为这是我的第一篇文章,我还不能嵌入

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).我在 Edge 中编码,但切换到 Chrome 并没有改变任何东西(可能是因为它们都是基于 Chromium 的)。 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.但脚本本身运行良好,无论它们是在容器绑定文件中还是在编辑器本身中运行。

EDIT:编辑:

This V8 debugging issue has been fixed by Google. Google 已修复此 V8 调试问题。

(as of September 1, 2020) (截至 2020 年 9 月 1 日)

Original answer:原答案:

V8 debugging is currently experiencing bugs V8调试目前遇到bug

(as of July 23, 2020) (截至 2020 年 7 月 23 日)

Using the debugger results in non-responsive UI (reports vary), server responses of 409 , breakpoints hang execution.使用调试器会导致 UI 无响应(报告不同)、服务器响应为409 、断点挂起执行。 Star the issue linked to below if you are experiencing similar behavior.如果您遇到类似行为,请在下方链接到的问题加注星标。

Link to Issue in Google's IssueTracker: "Debug mode not responsive in V8"链接到 Google 的 IssueTracker 中的问题:“调试模式在 V8 中没有响应”

What you can do for now while this bug exists is click "Run->Disable new App Scripts runtime"存在此错误时,您现在可以做的是单击“运行->禁用新的应用程序脚本运行时”

That will get the debugger working again but it will obviously disable any new features in the V8 runtime.这将使调试器再次工作,但显然会禁用 V8 运行时中的任何新功能。 If you have a simple script it probably won't affect much.如果您有一个简单的脚本,它可能不会有太大影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM