Skip to content
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

[BUGFIX] Ensure Ember build is complete. #349

Closed
wants to merge 1 commit into from

Conversation

patcoll
Copy link

@patcoll patcoll commented Dec 10, 2015

Checks to see if index.html file exists for each app before declaring the build complete. Fixes #331.

Checks to see if index.html file exists for each app before declaring the build complete. Fixes thoughtbot#331.
@@ -32,7 +32,7 @@ def wait!
attr_reader :name, :paths

def complete?
!paths.lockfile.exist?
!paths.lockfile.exist? && paths.dist.join("index.html").exist?
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this fix the bug you've been seeing?

The addon creates the lockfile when the build starts, then removes it when it's finished.

If the lockfile no longer exists, I'm not sure what good waiting on the index.html file will do.

It's likely that it'll hang indefinitely

If this DOES fix your issue, I'm curious what would make the index.html file suddenly materialize, outside the addon-managed build cycle

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it does fix my issue.

I couldn't find where the lockfile gets removed... I looked but no luck. More correct behavior would be to wait until index.html exists in dist before the lockfile gets removed.

Overall, expected behavior is that index.html should exist before declaring build done though, right? Open to suggestions on where to ensure that logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

@patcoll the lockfile is removed by https://github.com/rondale-sc/ember-cli-rails-addon/blob/cadb98ad22462664fda501fb7213649123fd4c63/index.js#L63-L65.

I agree, the build should block until index.html exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

@patcoll one thing I couldn't clarify before the end of our session:

Are you using rack-timeout or have any other request timeout strategies?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I do. My rack-timeout logic looks like this (in a Rails initializer):

if Rails.env.development? or Rails.env.test?
  Rack::Timeout.timeout = 60
else
  Rack::Timeout.timeout = 15  # seconds
end

With the newest non-Sprockets builds it never reaches anywhere near 15 seconds of initial load time. It's more like 5 seconds on average right now.

Copy link
Author

Choose a reason for hiding this comment

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

Hm, interesting. Could be a fsExtra.copySync bug or similar.

Copy link
Contributor

Choose a reason for hiding this comment

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

The addon no longer copies the index.html file:

rondale-sc/ember-cli-rails-addon@fd6d6ba

Copying the index was a means of integrating with Sprockets, and is no longer necessary.

@patcoll
Copy link
Author

patcoll commented Dec 10, 2015

I'll use these two versions and see if that removal of fs-extra fixes my issue:

@patcoll
Copy link
Author

patcoll commented Dec 10, 2015

Nope. It took 5-6 tries to get error #331, but I'm still getting it. Same one as in the gist.

@patcoll
Copy link
Author

patcoll commented Dec 10, 2015

Definitely seems like a race condition of some sort.

seanpdoyle added a commit to rondale-sc/ember-cli-rails-addon that referenced this pull request Dec 11, 2015
Closes [#331].
Closes [#349].

According to the [addon hook documentation][hooks]:

`#postBuild`

> Gives access to the result of the tree, and the location of the output.

`#outputReady`

> Hook called after the build has been processed and the files have been
> copied to the output directory

Since we're now blocking until the `index.html` it built and in the
output directory, `outputReady` is the behavior we depend on.

[hooks]: https://github.com/ember-cli/ember-cli/blob/082d559757b3d6d186fc1c3cd1b7c2bb1ad10b3f/ADDON_HOOKS.md#outputready
[#331]: thoughtbot/ember-cli-rails#331
[#349]: thoughtbot/ember-cli-rails#349
@seanpdoyle
Copy link
Contributor

@patcoll Could you please try out rondale-sc/ember-cli-rails-addon#27?

@patcoll
Copy link
Author

patcoll commented Dec 11, 2015

That totally works. You're a savant. I'm closing this.

@patcoll patcoll closed this Dec 11, 2015
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

Successfully merging this pull request may close these issues.

2 participants