Skip to content

Server rendering crashes in production with sprockets-rails < 2.2.2 #544

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
tf opened this issue Jun 3, 2016 · 4 comments · Fixed by #545
Closed

Server rendering crashes in production with sprockets-rails < 2.2.2 #544

tf opened this issue Jun 3, 2016 · 4 comments · Fixed by #545

Comments

@tf
Copy link
Contributor

tf commented Jun 3, 2016

#430 introduced the ManifestContainer which uses Rails.application.assets_manifest. This method was introduced by sprockets-rails 2.2.2. If Rails.config.assets.compile is set to false (which it is by default in production) SprocketsRenderer no longer uses EnvironmentContainer and causes the exception:

ActionView::Template::Error (undefined method `assets_manifest' for #<Xxx::Application:0x007f5464c7b180>):

  react-rails (1.6.2) lib/react/server_rendering/manifest_container.rb:9:in `initialize'
  react-rails (1.6.2) lib/react/server_rendering/sprockets_renderer.rb:70:in `new'
  react-rails (1.6.2) lib/react/server_rendering/sprockets_renderer.rb:70:in `asset_container'
  react-rails (1.6.2) lib/react/server_rendering/sprockets_renderer.rb:22:in `block in initialize'

I can see two possibilities:

  1. Fallback to EnvironmentContainer for sprockets-rails < 2.2.2
  2. Make the sprockets-rails dependency explicit

There are Rails version though (e.g. 4.0.5) that depend on sprocket-rails ~> 2.0.0.

@rmosolgo
Copy link
Member

rmosolgo commented Jun 3, 2016

Hmm, I see what you mean, that logic for choosing a container could be improved. Option 1. sounds best to me, do you want to give it a try?

In the meantime, I think you can work around it by manually choosing EnvironmentContainer:

React::ServerRendering::SprocketsRenderer.asset_container_class = React::ServerRendering::SprocketsRenderer::EnvironmentContainer

@tf
Copy link
Contributor Author

tf commented Jun 3, 2016

Yes, that's what I did. I can submit a PR. Do you want me to feature detect assets_manifest with repond_to? or check Sprockets::Rails::VERSION?

@rmosolgo
Copy link
Member

rmosolgo commented Jun 3, 2016

feature detection sounds good to me!

@tf
Copy link
Contributor Author

tf commented Jun 4, 2016

I'll submitted a PR (#545). Would be great if you could take a look.

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 a pull request may close this issue.

2 participants