Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug a command-line Dart app that uses async? (breakpoints not working)

The debugger in IntelliJ or the Dart Editor won't stop at the breakpoint for this code:

main() async {
    var x = 1;
    bool stop = true; // breakpoint here
}

... but does for this code:

main() {
    var x = 1;
    bool stop = true; // breakpoint here
}

Dart SDK 1.8.3 and latest stable releases on both IDEs.

like image 685
wjohnson Avatar asked Dec 19 '14 07:12

wjohnson


People also ask

How do I debug an app in Dart?

Open Dart DevTools to debug the app that’s running in the current window. If Dart Debug Extension is installed and you used the --debug-extension flag to webdev, click the Dart logo at the top right of the browser window. If you used the --debug flag to webdev, press Alt + D (or Option + D on macOS).

What are the best tools to debug Android apps?

DevTools, a suite of performance and profiling tools that run in a browser. Android Studio/IntelliJ, and VS Code (enabled with the Flutter and Dart plugins) support a built-in source-level debugger with the ability to set breakpoints, step through code, and examine values.

How do I enable and use Dart DevTools?

To enable Dart DevTools, add the --debug or --debug-extension option (at the command line or through your IDE): When running your app using the --debug flag of webdev , you can open Dart DevTools by pressing Alt + D (or Option + D on macOS).

Is async code more difficult to debug?

However, while it can improve your program’s overall throughput, async code is still not exempt from bugs! Writing async code makes debugging more difficult when potential deadlocks, vague error messages, and finding which task (s) are causing a bug are thrown into the mix.


1 Answers

This is a known issue that is fixed in the dev channel and will be released in the 1.9 stable channel. See Breakpoint set inside of async function does not trigger.

like image 149
Alexandre Ardhuin Avatar answered Nov 09 '22 07:11

Alexandre Ardhuin