Repository navigation
Support debugging build_runner code generation (inc breakpoints) #6199
Copy link
Copy link
Open
Labels
blocked on dart / flutterRequires a change in Dart or Flutter to progressRequires a change in Dart or Flutter to progressin debuggingRelates to the debug adapter or process of running debug sessionsRelates 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.An enhancement or improvement that should be listed in release notes but is not a bug fix.
Milestone
Description
Activity
- 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 - addedis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.An 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 sessionsRelates to the debug adapter or process of running debug sessions
on Sep 30, 2026 - changed the title
[-]Support debugging build_runner code generation with breakpoints[/-][+]Support debugging build_runner code generation (inc breakpoints)[/+]on Sep 30, 2026 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.canonicalizeor 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?
- addedblocked on dart / flutterRequires a change in Dart or Flutter to progressRequires a change in Dart or Flutter to progress
on Oct 6, 2026
Metadata
Metadata
Assignees
Labels
blocked on dart / flutterRequires a change in Dart or Flutter to progressRequires a change in Dart or Flutter to progressin debuggingRelates to the debug adapter or process of running debug sessionsRelates 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.An enhancement or improvement that should be listed in release notes but is not a bug fix.
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 fromdart:developer.To Reproduce
The Dart VM service is listening onprintlines inlib/generator.dartF5and pasting the URL into the popup dialogvmServiceUriin.vscode/launch.json. Keep in mind that the URL has to be updated after running thebuild_runnercommandStep Overaction in the debugger"--pause-isolates-on-start"argument (see below)debugger()statementContinueaction in the debuggerdebugger()statement and repeat the above starting at step 3Code generation command:
"--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 breakExpected behavior
The debugger breaks on both
debugger()statements and VSCode breakpoints.Additional Information
.dart_tool/build/entrypoint/build.dartbuild_runnerspawning a new process to do the building. The debugger then cannot debug this process. See.dart_tool/build/entrypoint/build.dartSystem Information