From d47a5275538f1c0ed2a4f3acff19809ebb5f59c7 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 30 Aug 2023 13:31:49 -0700 Subject: [PATCH] Check if we can read assets before asking for their digests (#3566) --- build_resolvers/CHANGELOG.md | 5 +++++ build_resolvers/lib/builder.dart | 13 ++++++++----- build_resolvers/pubspec.yaml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build_resolvers/CHANGELOG.md b/build_resolvers/CHANGELOG.md index 98fafd65d..57ecfe63e 100644 --- a/build_resolvers/CHANGELOG.md +++ b/build_resolvers/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.3.1 + +- Fix a bug in the transitive digest builder, ensure we check if assets are + readable before asking for their digest. + ## 2.3.0 - Improve performance for resolves by adding a builder which serializes diff --git a/build_resolvers/lib/builder.dart b/build_resolvers/lib/builder.dart index 2fe514d5f..04b0359fb 100644 --- a/build_resolvers/lib/builder.dart +++ b/build_resolvers/lib/builder.dart @@ -37,11 +37,8 @@ class _TransitiveDigestsBuilder extends Builder { continue; } - // Otherwise, add its digest and queue all its dependencies to crawl. - byteSink.add((await buildStep.digest(next)).bytes); - final deps = await dependenciesOf(next, buildStep); - if (deps == null) { - // We warn here but do not fail, the downside is slower builds. + // We warn here but do not fail, the downside is slower builds. + if (!(await buildStep.canRead(next))) { log.warning(''' Unable to read asset, could not compute transitive deps: $next @@ -50,6 +47,12 @@ https://github.com/dart-lang/build/blob/master/docs/faq.md#unable-to-read-asset- return; } + // Otherwise, add its digest and queue all its dependencies to crawl. + byteSink.add((await buildStep.digest(next)).bytes); + + // We know this isn't null since we already checked if we can read `next`. + final deps = (await dependenciesOf(next, buildStep))!; + // Add all previously unseen deps to the queue. for (final dep in deps) { if (seen.add(dep)) queue.add(dep); diff --git a/build_resolvers/pubspec.yaml b/build_resolvers/pubspec.yaml index 157ff7917..872c99f42 100644 --- a/build_resolvers/pubspec.yaml +++ b/build_resolvers/pubspec.yaml @@ -1,5 +1,5 @@ name: build_resolvers -version: 2.3.0 +version: 2.3.1 description: Resolve Dart code in a Builder repository: https://github.com/dart-lang/build/tree/master/build_resolvers