-
Notifications
You must be signed in to change notification settings - Fork 214
Bug: build_runner fails to cleanup outdated outputs #3875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks! Do you think this is a regression, or an old issue? If I broke something recently I should try to figure out why; if it's an older issue it'll need to wait a little longer until the current refactoring is done. |
@davidmorgan I can try to reproduce it with an older build_runner version if that helps. What would be the right version to do that with? |
That would be helpful, yes please. There are a lot of packages :) maybe try
and see if it picks something sensible? |
It appears to be a longer standing bug. I could reproduce with Dart 3.5 + build_runner 2.4.8 and with Dart 3.4 + build_runner 2.4.2. |
Fwiw, the test for this is here https://github.com/dart-lang/build/blob/master/build_runner/test/generate/watch_test.dart#L911. |
Yes but not really. If I simply delete the first file by hand, the rest is removed fine. |
👍 I can reproduce the issue, and yeah it seems specific to whether the output is created based on some condition in the builder, interesting. |
Thanks Kilian, thanks Jake :) will see if it's possible to get a fix into the next release, probably a week or two away since a pile of things are mid refactor. |
Hi @davidmorgan, whats the current status of this? |
@schultek I think I found the place where it needs fixing; once the performance refactoring release is out I'll try it. "A week or two away" turned out to be very optimistic :) but now I think the next release really is just a week or two away. |
I am investigating this build_runner error when using Jaspr. After some digging I found a reproducible setup and think its a general build_runner bug. It boils down to the following:
I have two builders:
.a
and generates.b
(e.g.main.a
->main.b
).b
and generates.c
(e.g.main.b
->main.c
)Builder A has some logic that it only conditionally generates
.b
files and that condition might change while watching the files (dart run build_runner watch
).When that happens, Builder A no longer outputs
main.b
. At that point I expect build_runner to also cleanupmain.c
since Builder B is also no longer executed since it doesn't have any input. Howevermain.c
still persists with now outdated contents.To reproduce do the following steps:
build
as a dep andbuild_runner
as a dev dep.build.yaml
lib/builders.dart
lib/test.a
test on
dart run build_runner watch -v
lib/test.b
andlib/test.c
being generated.lib/test.a
totest off
lib/test.b
correctly being removed, butlib/test.c
wrongly being still there.In the real-world case I experienced, BuilderA is a custom builder by Jaspr that generates
web/<filename>.dart
files that should be compiled to js. BuilderB isddc_modules
frompackage:build_web_compilers
that outputs.ddc.module
files for each.dart
file. The error occurs in theddc
builder that for each.ddc.module
tries to read the respective.dart
file, which doesn't exist for an outdated module.You can reproduce the error by creating a new Jaspr project (
jaspr create testapp
), startingbuild_runner watch
and removing the@client
annotation from e.g.lib/pages/about.dart
.dart --version
: Dart SDK version: 3.7.0 (stable) (Wed Feb 5 04:53:58 2025 -0800) on "macos_arm64"build_runner: ^2.4.15
(latest)build: ^2.4.2
(latest)The text was updated successfully, but these errors were encountered: