Skip to content

Snapshots expose warnings and errors that are confusing #1929

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

Closed
natebosch opened this issue Dec 11, 2018 · 9 comments
Closed

Snapshots expose warnings and errors that are confusing #1929

natebosch opened this issue Dec 11, 2018 · 9 comments

Comments

@natebosch
Copy link
Member

Running from a stale snapshot can trigger any number of warnings or errors. Typically this is fine because we'll correctly identify the situation and recreate the snapshot, then the followup build should be successful.

For example you might see a [WARNING] some/file.dart was not found in the asset graph, incremental builds will not work.. This looks scary, but the build will likely succeed on the second run.

I wonder if we can more eagerly invalidate the snapshot by detecting situations where we expect it would fail when we run it.

@jakemac53
Copy link
Contributor

The particular one you mention gets tricky - it can happen due to poorly configured targets too (some sources not being included in any targets). So we can't use that alone as an indication that we need to re-snapshot. We could potentially use the existence of a previous asset graph and that error as an indication that we need to re-snapshot though (and throw a BuildScriptChanged exception).

Are there other specific scenarios we are aware of that are weird?

@natebosch
Copy link
Member Author

You can hit this after a pub upgrade. That might be the only scenario we need to check for specially. Maybe we should keep a hash of the package versions and invalidate the snapshot before running it when that changes.

@jakemac53
Copy link
Contributor

jakemac53 commented Dec 12, 2018

When you have path dependencies (or builders implemented in the current package) this can happen at any time so that makes it more difficult.

@grouma
Copy link
Member

grouma commented Jul 22, 2019

Hitting something similar to this today. Rolled a new version of build_runner which expects a new argument for the daemon command. We aren't updating the snapshot script which is causing a failure. Users have to pub run build_runner clean to resolve the issue but we don't automatically direct users to do so.

See:
dart-lang/webdev#375

@jakemac53
Copy link
Contributor

Would one fix here be to record the last version of build_daemon that the snapshot was ran with, and make sure to re-snapshot if that changes? That wouldn't help if you have a path override or something but those cases should be limited to us and rare even then.

@jakemac53
Copy link
Contributor

Alternatively we could always re-snapshot if we hit any unhandled exception?

@natebosch
Copy link
Member Author

I think we should separately record a hash of the pub solve and resnapshot on any pub get.

@jakemac53
Copy link
Contributor

I think we should separately record a hash of the pub solve and resnapshot on any pub get.

My hesitation with that is its overly pessimistic and comes at a pretty high cost, for small projects the snapshot time can be even longer than the entire build time.

jakemac53 added a commit that referenced this issue Jul 24, 2019
…#2374)

Related to #1929

I ended up going with the build_runner/build_daemon version check since the error handling was going to get pretty gnarly once I looked at what it would actually take.

The check is done by examining where a fake uri resolves to for each package, since that actually catches some cases the version check alone wouldn't catch and it doesn't require reading/parsing any files.

Note that this will not catch cases where you have a path override on these packages as that path won't ever change even if the packages do, but that should only affect us internally.
@jakemac53
Copy link
Contributor

I believe we handle this much better today (and actually do incremental rebuilds too)

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

No branches or pull requests

3 participants