Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run asynchronous code in chrome devtools when script execution 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

enter image description here

N.B.

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

like image 735
srghma Avatar asked Dec 19 '18 14:12

srghma


People also ask

How do I pause a script execution in Chrome?

Pausing script execution is F8 (when looking at the Sources tab, as of Chrome 45) or Ctrl + / .

How do I debug async in Chrome?

# Enable async debugging in ChromeGo to the Sources panel of Chrome Canary DevTools. Next to the Call Stack panel on the right hand side, there is a new checkbox for "Async". Toggle the checkbox to turn async debugging on or off. (Although once it's on, you may not ever want to turn it off.)

How do I pause Dev Tools in Chrome?

In order to “freeze” the browser, we will need to first open devTools, and then use F8 (fn + F8 on osx) to pause script execution whenever you want. The debugger will pause, and you'll be able to inspect the elements on the screen in their current state, Simple as that!

How do I pause js in Dev Tools?

Alternatively, you can pause on a particular line of JavaScript. To try this out, use the following shortcut from the Sources Panel: Mac: F8 or _Command + \_ Windows: F8 or _Control + \_


1 Answers

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)

like image 158
srghma Avatar answered Sep 25 '22 01:09

srghma