简体   繁体   English

Chrome 开发者工具在没有设置断点的地方不断中断

[英]Chrome Developer Tools keeps breaking where no breakpoints are set

When debugging JavaScript code using Chrome Developer Tools the debugger pauses on code where breakpoints are not set.使用 Chrome 开发人员工具调试 JavaScript 代码时,调试器会在未设置断点的代码处暂停。 I don't have the Pause on exceptions feature enabled, and there definitely are not breakpoints set (see attached image).我没有启用Pause on exceptions功能,而且肯定没有设置断点(见附图)。

I asked a similar question before which was helpful but didn't quite solve this issue (previously I had the Pause on exceptions enabled).我之前问过一个类似的问题,这个问题很有帮助,但并没有完全解决这个问题(之前我启用了Pause on exceptions )。 In the example below I swapped out the minified version of kendo.all.min.js for the unminified version, which allows me to see where the script execution is being paused, but I don't know why it is being paused.在下面的示例中,我将kendo.all.min.js的缩小版本替换为未缩小版本,这使我可以看到脚本执行暂停的位置,但我不知道为什么会暂停。 This happens a lot with jquery.min.js too. jquery.min.js也经常发生这种情况。

在此处输入图像描述

I fixed my breakpoints problem by clicking the "Restore defaults and reload" button located in the “Settings” section.我通过单击“设置”部分中的“恢复默认值并重新加载”按钮修复了断点问题。 To find the button: In Developer Tools click the cogged wheel next to the top right three vertical dots.找到按钮:在开发者工具中,点击右上角三个垂直点旁边的齿轮。 (Note: If using older versions of Google Chrome, click on the top right three vertical dots and then select “Settings F1”). (注意:如果使用旧版本的谷歌浏览器,点击右上角的三个垂直圆点,然后选择“设置F1”)。 The button “Restore defaults and reload” is at the bottom right. “恢复默认值并重新加载”按钮位于右下角。

Also note that it really restores defaults - you lose all previously saved breakpoints and any files you have open in Developer Tools will be closed.另请注意,它确实会恢复默认值 - 您会丢失所有以前保存的断点,并且您在开发人员工具中打开的任何文件都将被关闭。

I got this solution from: Chrome javascript debugger breakpoints don't do anything?我的解决方案来自: Chrome javascript debugger breakpoints don't do any?

F8 has two functionalitys. F8 有两个功能。 1. Skip ot next Breakpoint, 2.stop wherever the Browser is executing code. 1. 跳过下一个断点, 2. 在浏览器执行代码的地方停止。 This works even if you have no breakpoint set.即使您没有设置断点,这也有效。 For example spamming F8 when you forgot to deactivate breakpoints might cause the browser to stop anywhere.例如,当您忘记停用断点时发送垃圾邮件 F8 可能会导致浏览器在任何地方停止。

When you go to the debugger shortcuts you can see that F8 has the functionality to Pause / Continue.当您转到调试器快捷方式时,您可以看到 F8 具有暂停/继续的功能。 But it sadly seems like you can't split them on two different keybinds.但遗憾的是,您似乎无法将它们拆分为两个不同的键绑定。

Since I know this feature I never ran into this "bug" anymore.因为我知道这个功能,所以我再也没有遇到过这个“错误”。

只需禁用缓存并重新加载页面,断点将再次显示

已接受的导入/导出 Chrome devtools 断点和计算机之间设置的答案提醒我检查“devtools-on-devtools”,并在DevTools 的内部应用程序本地存储中删除关键breakpoints的 JSON 列表值的错误元素以修复我同样的问题没有重置一切

I was able to resolve this by updating Chrome.我可以通过更新 Chrome 来解决这个问题。 I don't think the version matters, just the process of updating resets all of the breakpoints that have been stored in the cache.我认为版本无关紧要,只是更新过程会重置所有已存储在缓存中的断点。

I'm posting this answer in case it will help someone who, like me, missed an important clue as to the cause of the phantom breakpoint behavior.我发布这个答案是为了帮助像我这样错过了关于幻像断点行为原因的重要线索的人。 In my case, it was "user error" --mine.就我而言,这是“用户错误”——我的。 The root cause was a forgotten "debugger;"根本原因是一个被遗忘的“调试器”; statement in a JavaScript file that was itself generated from TypeScript. I had removed the debugger; JavaScript 文件中的语句,该文件本身是从 TypeScript 生成的。我已经删除了调试器; statement from TypeScript locally, run and tested without issue from localhost.来自本地 TypeScript 的语句,在本地主机上运行和测试没有问题。 But I had pushed the version with the statement to remote and it built and released to our dev site with the statement present.但是我已经将带有声明的版本推送到远程,并且它在存在声明的情况下构建并发布到我们的开发站点。 The dev site build excludes the TypeScript source files.开发站点构建不包括 TypeScript 源文件。 When the debugger statement was hit, Chrome tried to load the.ts source and displayed "Could not load content..." I just assumed it was at a breakpoint (I'd set many during testing).当调试器语句被命中时,Chrome 尝试加载 .ts 源并显示“无法加载内容...”我只是假设它处于断点(我在测试期间设置了很多)。 And when I saw "No breakpoint" I assumed Chrome was experiencing the issue addressed in this thread.当我看到“无断点”时,我认为 Chrome 遇到了该线程中解决的问题。 If I'd bothered to look in the Call Stack trace, I would have seen the source code line in the.ts file and pretty quickly figured it out.如果我费心查看调用堆栈跟踪,我会看到 .ts 文件中的源代码行并很快弄清楚。 Here's a screenshot:这是一个截图:

在此处输入图像描述

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

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