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'));
Rejecting a promise synchronously has exactly the same behavior as rejecting it asynchronously. The difference you are seeing is Chrome's "pause on uncaught exception" thinking the promise doesn't have a rejection handler attached when it is rejected.
TL;DR Right click in the area where you'd normally set breakpoints, select “never pause here” and you can prevent the debugger from stopping on exceptions or debugger statements.
Open Chrome DevTools. Press Control+Shift+P or Command+Shift+P (Mac) to open the Command Menu. Start typing javascript , select Disable JavaScript, and then press Enter to run the command. JavaScript is now disabled.
A 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;
expressionReturningPromise().then( r => {
console.log('done');
debugger;
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With