Visitar URL original
Support debugging build_runner code generation (inc breakpoints) · Issue #6199 · Dart-Code/Dart-Code · GitHub
Skip to content

Support debugging build_runner code generation (inc breakpoints) #6199

Description

@LennartCode

When generating code using the build runner (see reproduction info), the debugger does not break on breakpoints set in VSCode, instead it continues execution beyond them.

Notably, the debugger does break on debugger() statements from dart:developer.

To Reproduce

  1. Clone the example repository
  2. Download the dependencies
  3. Run the code generation command (see below)
  4. Copy the URL printed to the terminal after The Dart VM service is listening on
  5. Place a breakpoint on one of the print lines in lib/generator.dart
  6. Invoke the Dart Debugger
    • Usually using F5 and pasting the URL into the popup dialog
    • Alternatively, copy the URL into the value field of vmServiceUri in .vscode/launch.json. Keep in mind that the URL has to be updated after running the build_runner command
  7. Observe that the breakpoints are greyed out in VSCode and say "Breakpoint has not yet been resolved!" on hover
  8. Select the Step Over action in the debugger
    • This is not part of the problem, but necessary due to the "--pause-isolates-on-start" argument (see below)
  9. Observe that the debugger halts at the debugger() statement
    • This might be non-immediate. Sometimes, it took ~30 seconds on my machine
  10. Select the Continue action in the debugger
  11. Observe that the debugger does not halt on the breakpoint
  12. Comment out the debugger() statement and repeat the above starting at step 3
  13. Observe that the debugger does not halt at all

Code generation command:

  • The "--pause-isolates-on-start" argument is not strictly necessary but helps manually debugging this debugging error situation, because this way, one can manually decide when the debugger starts and observe when it does/does not break
dart run build_runner build --force-jit --dart-jit-vm-arg "--observe" --dart-jit-vm-arg "--pause-isolates-on-start"

Expected behavior
The debugger breaks on both debugger() statements and VSCode breakpoints.

Additional Information

  • The debugger breaks on VSCode breakpoints set in .dart_tool/build/entrypoint/build.dart
  • There has been speculation that this might be due build_runner spawning a new process to do the building. The debugger then cannot debug this process. See .dart_tool/build/entrypoint/build.dart
  • There has been a discussion with @DanTup on Discord in late August about this. All relevant information is contained in this issue

System Information

  • Operating System and version: Windows 10 Enterprise 10.0
  • VS Code version: win 1.138.0
  • Dart extension version: 3.142.0
  • Dart/Flutter SDK version: Dart: 3.11.5; Flutter: 3.41.7

Activity

  1. changed the title [-]Debugger does not break on breakpoints but `debugger()` statements during code generation[/-] [+]Support debugging build_runner code generation with breakpoints[/+] on Sep 30, 2026
  2. added this to the v3.146.0 milestone on Sep 30, 2026
  3. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    in debuggingRelates to the debug adapter or process of running debug sessions
    on Sep 30, 2026
  4. changed the title [-]Support debugging build_runner code generation with breakpoints[/-] [+]Support debugging build_runner code generation (inc breakpoints)[/+] on Sep 30, 2026
  5. self-assigned this
    on Sep 30, 2026
  6. DanTup commented on Oct 6, 2026

    @DanTup
    Member

    I can reproduce this, and I think the issue is due to the VM treating the paths as case-sensitive and our request to set a breakpoint looks like:

    {
    	"jsonrpc": "2.0",
    	"id": "1158",
    	"method": "addBreakpointWithScriptUri",
    	"params": {
    		"isolateId": "isolates/2422819358888035",
    		"scriptUri": "file:///D:/Dev/Temp%20Projects/code_generation_debugging/lib/generator.dart",
    		"line": 18
    	}
    }

    However, the VM has the script loaded with a path of:

    file:///d:/dev/temp%20projects/code_generation_debugging/lib/generator.dart
    

    @davidmorgan this seems like the same issue we touched on at dart-lang/sdk#28895 (comment)

    So I don't think fixing it in only the analyzer would solve everything (since this is build_runner + the VM with no analyzer).

    I think these two things are fundamentally incompatible:

    • the VM treating file URIs as case-sensitive on Windows
    • build_runner (or other tools) using path.canonicalize or otherwise changing the case in a way that other tools being used have not

    I think for this to work, we need to change one of those, but I don't know which is the least complex. Do you know what the implications of removing the canonicalize from build_runner would be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

blocked on dart / flutterRequires a change in Dart or Flutter to progressin debuggingRelates to the debug adapter or process of running debug sessionsis bugis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions