javascript - How to run asynchronous code in chrome devtools when script execution is paused? - Stack Overflow

await Promise.resolve(1) in chrome devtools (chrome version 70.0.3538.77) resolves to:1 when script exe

await Promise.resolve(1) in chrome devtools (chrome version 70.0.3538.77) resolves to:

  • 1 when script execution is not paused
  • Promise <pending> when script execution is paused

How to resolve it to 1 when script execution is paused

N.B.

this question continues chrome debugger promises dont resolve while paused? to find the exact way to resolve promises when chrome is paused

await Promise.resolve(1) in chrome devtools (chrome version 70.0.3538.77) resolves to:

  • 1 when script execution is not paused
  • Promise <pending> when script execution is paused

How to resolve it to 1 when script execution is paused

N.B.

this question continues chrome debugger promises dont resolve while paused? to find the exact way to resolve promises when chrome is paused

Share Improve this question edited Dec 19, 2018 at 14:16 srghma asked Dec 19, 2018 at 14:05 srghmasrghma 5,3932 gold badges41 silver badges62 bronze badges 13
  • 2 console.log(await Promise.resolve(1)) – Keith Commented Dec 19, 2018 at 14:18
  • 1 @Keith, no, it resolves to Promise <pending> too – srghma Commented Dec 19, 2018 at 14:21
  • @Keith, here is the reproduction imgur./a/oDDDet9 – srghma Commented Dec 19, 2018 at 14:23
  • 1 @DanielBeck I dont want to execute the script, I want to execute async functions while script is paused (think about it, I can calculate ordinary functions while paused, but not async calls, why?) – srghma Commented Dec 19, 2018 at 14:29
  • 2 Yes,. JS is single threaded, this means it has 1 single message loop. When you pause, it will pause the message loop. If it didn't it would make debugging even harder. What problem are you trying to solve, I wonder if this is an X/Y problem. – Keith Commented Dec 19, 2018 at 14:45
 |  Show 8 more ments

1 Answer 1

Reset to default 2

Answer - it's not possible to make promises resolve WHEN js is paused in chrome, even promises that are created in console

(js is single threaded)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745277066a4620103.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信