Skip to content

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Oct 4, 2025

With recent changes to the bootstrapping logic, builders have become almost impossible to debug in real projects:

  • Running build_runner itself with --observe doesn't do much because most of the build happens in a sub-process.
  • The sub-process can't be started manually because it needs state sent to it from stdin, which is tricky to do when launching it from editors.

I've also started a discussion on this: #4242. Originally I wanted to wait for feedback but this turned out to be fairly simple in the end, so here's a PR :)

This adds the --debug-builders flag. When set, the subprocess running the build will launch with --observe and --pause-isolates-on-start. This makes Dart print out the VM service and devtools URLs, so one can attach a debugger, set breakpoints and then resume the build.

I've tested these changes manually, I'm not sure how a good automated test for this could look like. Start a build, assert that a "VM service URL" line is printed on stdout and then kill it?

@davidmorgan
Copy link
Contributor

Thanks!

I already felt the need for this myself :)

What do you think about instead of --debug-builders, having a multi-option --dart-arg that just passes through anything to dart run before the script? Then you would do --dart-arg=--observe --dart-arg=--pause-isolates-on-start or anything else you want. It can be wired up pretty much exactly as you already have it.

When AOT compile is added I guess the same flags won't apply to both, so maybe the name should be more explicit ... maybe --dart-jit-vm-arg?

For testing, it's easy to do a test that runs, checks output and kills using a recently-added test type, it would be like the "watch" test because that deals with a running process then killing it, too

var watch = await tester.start('root_pkg', 'dart run build_runner watch');

I suggest adding a new test named something like build_command_vm_arg_test.dart.

@davidmorgan davidmorgan self-requested a review October 7, 2025 06:49
Copy link

github-actions bot commented Oct 7, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

@davidmorgan davidmorgan merged commit 3fc9510 into dart-lang:master Oct 8, 2025
36 checks passed
@davidmorgan
Copy link
Contributor

Thanks :) I guess I'll get to releasing a new version some time next week, feel free to nudge me if it starts to be too long :)

@simolus3 simolus3 deleted the debug-builders branch October 8, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants