Skip to content

Commit

Permalink
Check if we can read assets before asking for their digests (#3566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 authored Aug 30, 2023
1 parent 307a5ab commit d47a527
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 8 additions & 5 deletions build_resolvers/lib/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit d47a527

Please sign in to comment.