【发布时间】:2023-04-08 11:36:01
【问题描述】:
{
async function foo() {
return new Promise((resolve, reject) => {
setTimeout(resolve, 500)
})
}
async function bar() {
await foo()
console.info('foo done')
}
bar()
}
我在 chrome devtools 源选项卡中打开一个 sn-p,并将上面的代码放入其中。但我不能为此设置任何断点。只有在代码中没有 async/await 函数时才能添加断点。
更重要的是,我从未在 chrome devtools 中成功调试过任何 async/await 代码。有时添加的断点会移动到错误的位置,有时代码会在没有断点的地方暂停。
是不是chrome的bug?
【问题讨论】:
-
您可以使用
debugger;语句触发断点。
标签: javascript google-chrome async-await devtools