Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

fix silent (!) build failure when several source filepaths cannot be found #276

Merged
merged 4 commits into from
Dec 19, 2017

Conversation

vlukashov
Copy link
Contributor

@vlukashov vlukashov commented Dec 8, 2017

This PR ensures that the scan() method gets completed for every source file in the project. Currently, the scan method gets started but would never get completed if there is more than one missing source file dependency in dependencies tree.

A scan() of source file gets completed when all dependencies of that file are known (resolved or rejected). That's why when the project's sources stream is completed it's important to ensure all deferred source get rejected--not only the first one.

If some of the deferred dependencies remain pending, the analysis of the toplevel source file never continues after await this._cache.dependencyGraph.whenReady(resolvedUrl);.

This PR fixes https://github.com/Polymer/polymer-cli/issues/936, https://github.com/Polymer/polymer-cli/issues/904 and https://github.com/Polymer/polymer-build/issues/251.

It might be also related to https://github.com/Polymer/polymer-build/issues/272.

  • CHANGELOG.md has been updated

Viktor Lukashov added 3 commits December 8, 2017 11:11
The 'analyze' phase of the build process completes when all source files are analyzed (scanned). A source file is analized when all its dependencies are resolved or rejected. When the sources stream is complete, _all_ pending source file promises need to be rejected--not only the first one. If some of the deferred dependencies remain pending, the analysis of the toplevel source file never continues after 'await this._cache.dependencyGraph.whenReady(resolvedUrl);'. That leads of a premature end of the analysis phase (without any errors).
@jsilvermist
Copy link

Should there also be a test for a broken file path in a lazy import added as well? I believe the lazy import caused silent failure even if there was only 1 broken path, not needing 2 before it happened.

@vlukashov
Copy link
Contributor Author

It would be a good idea to investigate if Polymer/polymer-cli#904 would be fixed by the same change. I have not done that (and that's why there is no test case for lazy imports).

Would you like to contribute? Here is how:

  • create a fork of the polymer-build repo
  • add my fork as a remote (git remote add vlukashov https://github.com/vlukashov/polymer-build.git)
  • create a branch based on this PR (git checkout fix/251-silent-build-failures && git checkout -b your-own-branch-name)
  • add a test case for lazy imports
  • push the branch to your fork and create a pull request targeting either Polymer:master or vlukashov:fix/251-silent-build-failures

@jsilvermist
Copy link

Tested locally and seems to be fixed.

Created a PR for a commit adding the lazy-import test here:
vlukashov#1

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@vlukashov
Copy link
Contributor Author

@jsilvermist nice! I've just added your test case to the PR.

But now it looks like the Google CLA bot wants you to write here a comment explicitly stating that you do accept the CLA for this repo.

@jsilvermist
Copy link

Nah I've signed the CLA don't worry, it's just how the google bot acts if anyone adds a commit from a different author to a PR.

@keithbloom
Copy link

Hi

I have a build that is silently failing with a specific set of incorrect links

  1. A component with a <link rel="import"> to a component that is missing
  2. Two components that have <link rel="stylesheet"> where the stylesheet is missing

This configuration caused Polymer Build to fail silently. When I applied the fix in this PR the build fail correctly and echos the messages from Analyzer to the console.

The sooner this PR can be merged and released the better. This bug means the build process can fail without any indication of the problem.

@@ -249,7 +249,6 @@ export class BuildAnalyzer {
if (this.config.isSource(filePath)) {
const err = new Error(`Not found: ${filePath}`);
this.loader.rejectDeferredFile(filePath, err);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return is unintuitive. It seems dangerous to not process the remaining errors or close the dependencies steam. I also don't see how the test should show more errors with this addition. Does the modified test fail without this change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change removes the early return.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so I shouldn't do reviews on my phone on the subway :)

@justinfagnani justinfagnani merged commit 17e5762 into Polymer:master Dec 19, 2017
@justinfagnani
Copy link
Contributor

Thanks for the PR @vlukashov!

And thanks for the correction on the review @keithbloom :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants