admin管理员组

文章数量:1417674

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)

本文标签: javascriptHow to run asynchronous code in chrome devtools when script execution is pausedStack Overflow