为什么 Chrome 会在 jQuery 中的某行暂停?
每次我打开 Chrome 检查器刷新我的 Web 应用程序时,它都会暂停并带我到“源”选项卡,其中有一个红色大箭头图标指向 jQuery 中的一些奇怪的行。
我懂了
在调试器中暂停
在窗口中上部的
,并且因异常而暂停:DOMException
“源”选项卡上“调用堆栈”中的 DOMException。
据我所知,我还没有设置任何断点,并且这段代码之前没有抛出异常 - 那么发生了什么?
Every time I refresh my web app with the Chrome Inspector open it pauses and takes me to the sources tab with a big red arrow icon pointing to some weird line inside jQuery.
I see
Paused in debugger
in the top-middle of the window, and
Paused on exception: DOMException
in the Call Stack on the sources tab.
As far as I'm aware, I haven't set any breakpoints and this code wasn't throwing exceptions before - so what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
左下角的那个小暂停图标。颜色应该是黑色。单击它可循环选择多个断点选项。
That little pause icon in the lower left. Should be black in color. Click it to cycle through several breakpoint options.
我一直在调试,忘记删除断点。
I had been debugging and forgotten to remove a breakpoint.
另请检查您是否未在 XHR 断点下勾选“任何 XHR”。
Also check that you haven't ticked "Any XHR" under XHR Breakpoints.
要在 Windows 上的 Chrome 上禁用此功能。
在下面用红色圈出的“脚本”按钮中,循环到相同状态(“出现异常时不要暂停”)
To disable this on On Windows for Chrome.
In "Script" button circled in red below, cycle to same state ("Don't pause on Exceptions")
Visual Studio 调试解决方案
当我使用 MVC 5 和 razor 构建网站时,我遇到了同样的问题,显示“调试器中已暂停”。
对我来说解决问题的是:
删除代码中的所有断点(有些是在 JavaScript 代码中设置的)。
开始调试项目,单击“异常设置”选项卡,取消选中“JavaScript (Chrome) 异常”复选框。
停止调试 - 设置将在重新启动后首先应用
开始调试 - 不再“在调试器中暂停”
在此过程中的某个地方,我一定检查了“JavaScript (Chrome) 异常”复选框,然后忘记了它。
异常设置图像链接
Solution for Visual Studio debugging
I had the same problem with the "Paused in debugger" showing up when I was building a website with MVC 5 and razor.
What solved the problem for me was to:
Remove all breakpoints in the code (some were set in JavaScript code).
Start debugging the project, click the "Exception settings" tab, and deselected "JavaScript (Chrome) Exceptions" checkbox.
Stop debugging - Settings will apply first after a restart
Start debugging - no more "Paused in debugger"
Somewhere along the line, I must have checked the "JavaScript (Chrome) Exceptions" checkbox, and forgot about it.
Link to Exception Settings Image
这也可能导致问题
左上角的断点图标应为蓝色,如下所示(对于停用断点)
不应该像这样灰色
This can also cause the issue
Break Point icon at top left should be blue like this(For Deactivate BreakPoints)
Should not grey like this
通过关闭开发人员工具、刷新页面,然后打开开发人员工具,我能够清除使用 Chrome 时遇到的幻像断点。
I was able to clear a phantom breakpoint I had while using Chrome by closing developer tools, refreshing the page, and then opening developer tools.
对我来说这就是问题所在:
我必须取消选中任何 XHR 或 fetch 复选框
结论:我不知道这是否可以解决问题,但我猜如果您在名称中包含断点的任何选项卡中选中了任何复选框,只需取消选中它并看看是否可以它可以工作,取消选中左上方栏中的断点符号,直到它变成灰色,然后您需要点击左上方栏中的暂停或播放按钮,并且不会再出现任何内容。
for me this was the problem:
I had to uncheck the any XHR or fetch checkbox
Conclusion: I don't know if you if this will fix the problem but I guess that if you have any checkbox checked in any tab that has Breakpoints in its name just uncheck it and see if it works, and uncheck breakpoint symbol in the top left bar till it's grey, and then you will need to hit the pause or play button in the top left bar and nothing should appear any more.