Maybe I'm not debugging promises right but basically if you stop at break point and run async code it doesnt actually finishes until you resume execution and that's a problem. Debugger allows you to quickly experiment with multiple api methods... but you cant if you resume it
debugger;
//now type the following in console
Promise.resolve().then(()=> console.log('done'));
Maybe I'm not debugging promises right but basically if you stop at break point and run async code it doesnt actually finishes until you resume execution and that's a problem. Debugger allows you to quickly experiment with multiple api methods... but you cant if you resume it
debugger;
//now type the following in console
Promise.resolve().then(()=> console.log('done'));
Share
Improve this question
edited Nov 10, 2017 at 5:48
Muhammad Umer
asked Nov 10, 2017 at 5:42
Muhammad UmerMuhammad Umer
18.2k24 gold badges111 silver badges176 bronze badges
0
2 Answers
Reset to default 5A possible workaround for this is to put debugger
in your .then
callback as well. This won't work in all situations but it worked for my particular case of debugging node.js scripts before they exit:
insert this into the JS code that you want to debug
debugger;
- when the debugger stops, type the following at the console prompt:
expressionReturningPromise().then( r => { console.log('done'); debugger; });
- resume script execution
The dev tools will then pause on the debugger within the .then
callback and you'll have the resolved value of your promise available for examination.
It doesn't execute because the function in .then
is only called when the current "thread" is finished. This is the same for all asynchronous calls such as setTimeout
.