Skip to content

uninitialized constant React::ServerRendering #498

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
richardmatthewsdev opened this issue Mar 15, 2016 · 17 comments
Closed

uninitialized constant React::ServerRendering #498

richardmatthewsdev opened this issue Mar 15, 2016 · 17 comments

Comments

@richardmatthewsdev
Copy link

Hey,

We are getting an issue on our staging server where this gem appears to not be loading correctly. It is giving us this error.

uninitialized constant React::ServerRendering

The gem is working fine on development.

Thanks,

@rmosolgo
Copy link
Member

do you have the whole stack trace? could you share it?

@rmosolgo
Copy link
Member

(the stack trace includes really useful information, like what code is triggering the error and what code path made it happen!)

@richardmatthewsdev
Copy link
Author

Hey thanks for replying, here is our stack trace

NameError: uninitialized constant React::ServerRendering
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails/railtie.rb:79:in `block in <class:Railtie>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:34:in `call'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `each'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configuration.rb:59:in `after_initialize'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails/railtie.rb:77:in `<class:Railtie>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails/railtie.rb:5:in `<module:Rails>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails/railtie.rb:4:in `<module:React>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails/railtie.rb:3:in `<top (required)>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/rails.rb:2:in `<top (required)>'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react-rails.rb:2:in `<top (required)>'
        from (irb):1
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
        from /data/sites/natlib.uat.digitalnz.org/rails/releases/20160315212841/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'

@rmosolgo
Copy link
Member

Hmm so it doesn't event start, this is Rails 3.2 ....

@rmosolgo
Copy link
Member

Our tests run 3.2.21 and that passes, are you able to try that? Also, what's your Ruby version? (You can see which ones we test here: https://github.com/reactjs/react-rails/blob/master/.travis.yml)

@rmosolgo
Copy link
Member

I wonder if swapping the require order here would help:

https://github.com/reactjs/react-rails/blob/master/lib/react-rails.rb#L2-L3

The line in question is inside app.after_initialize so I would expect it not to matter but ... I don't know!

@richardmatthewsdev
Copy link
Author

Hey,

Our ruby version is 1.9.3 & rails is 3.2.12. We will try changing the require order. If that fixes it we will let you know.

Thanks,

@richardmatthewsdev
Copy link
Author

Hey,

We altered the order of the require statements and it fixed one of the problems. Before when we were in the console and we went require 'react-rails' we would get the error that I posted earlier. Now we get 'true' back, but our broken page gives this error.

undefined method `react_component' for #<#Class:0x000000061219b0:0x007f5b44a95410>>

Thanks for your quick replies!

@rmosolgo
Copy link
Member

Full stack trace?

@UberMouse
Copy link

Hi, just stepping in for @reinkaos as he is busy

Exception caught: NoMethodError: undefined method `react_component' for #<#<Class:0x0000000978cf40>:0x000000096bcb88>
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/app/views/schools/admin/school_profiles/show.html.erb:5:in `_app_views_schools_admin_school_profiles_show_html_erb___1818258834022774347_80818700'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template.rb:145:in `block in render'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications.rb:125:in `instrument'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template.rb:143:in `render'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316002143/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'

@UberMouse
Copy link

That line 5 is
<%= react_component 'SchoolAutoComplete', {school_profiles: @school_profile_data}, {prerender: true} %>

@rmosolgo
Copy link
Member

Hmmm it should come from the ViewHelper:

https://github.com/reactjs/react-rails/blob/master/lib/react/rails/view_helper.rb#L19

Which gets included by the Railtie:

https://github.com/reactjs/react-rails/blob/master/lib/react/rails/railtie.rb#L43

I wonder why it's not there ...

@UberMouse
Copy link

The same page works without issues in development and test environments. The gem is bundled correctly on the staging server but it seems like it's not being loaded correctly as when I open a rails console and go require 'react-rails' I get true instead of false. The gem is inside the assets group which I assume is the correct place for it.

@rmosolgo
Copy link
Member

inside the assets group

Does that mean it's used for assets:precompile, but not loaded to boot the app? If so, that would definitely cause problems. react-rails is needed at runtime if you're using view helpers!

Could you try moving it out of the assets group?

@UberMouse
Copy link

We've tried that but now we're getting a different error

Exception caught: RuntimeError: No compiled asset for react-server.js, was it precompiled?
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering/yaml_manifest_container.rb:13:in `find_asset'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering/sprockets_renderer.rb:22:in `block in initialize'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering/sprockets_renderer.rb:21:in `each'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering/sprockets_renderer.rb:21:in `initialize'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering.rb:22:in `new'
/data/sites/natlib.uat.digitalnz.org/rails/releases/20160316201754/vendor/bundle/ruby/1.9.1/gems/react-rails-1.6.2/lib/react/server_rendering.rb:22:in `create_renderer'

@rmosolgo
Copy link
Member

😢 a new surprise around every corner!

That's the same error we saw earlier, but only with Sprockets 3! #443 (comment)

@rmosolgo
Copy link
Member

rmosolgo commented Dec 9, 2016

I hope you were able to find something that works for you!

@rmosolgo rmosolgo closed this as completed Dec 9, 2016
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