Async Rails 3.1 problem with assets
-
26-10-2019 - |
Pergunta
I have a problem with assets on an asynchronous rails 3.1 application, I managed to build a minimal example showing my problem but it did not helped me much.
The application is really simple, what I did was: - create a fresh application with 3.1 (non rc) - add thin+Rack::FiberPool - setup bourbon (scss mixins) - run the application
Now I start a server with "rails server thin", after that any request will end up in a "stack level too deep" with only one backtrace line :/
Here is the minimal application: https://github.com/schmurfy/assets_crash
Here is the backtrace I get when doing a request: http://dl.dropbox.com/u/1313066/github/crash_assets.png
I tried to dig in to see where the problem was which led me in sass-rails in the file template_handlers.rb:
def sass_options(scope)
importer = self.importer(scope)
options = sass_options_from_rails(scope)
load_paths = (options[:load_paths] || []).dup
load_paths.unshift(importer)
# bnding.pry
options.merge(
:filename => eval_file,
:line => line,
:syntax => syntax,
:importer => importer,
:load_paths => load_paths,
:custom => {
:resolver => Resolver.new(scope)
}
)
end
I tried to explore with Pry (an irb alternative) and what I found is even more puzzling: While at the binding.pry line I can trigger a stack level too deep with:
{}.merge(:anything => Resolver.new(scope))
The result is immediate but I cannot find anything in that object which would explain the result.
Any lead would be welcome.
Solução
I finally found the answer: fibers only have 4Kb of stack space and Ruby on Rails is now too big to fit in this space :/
Outras dicas
I had the same problem, upgraded my ruby to 1.9.3-preview1 and built all my gems from the ground up now everything works.
EDIT: OK after playing with it a little more it really seems as if Rack::Fiberpool causes this issue. Got it back after I inserted Rack::Fiberpool back in my Rails stack...
Disable assets pipline in rails. Don't require sass-rails but instead require sass and sprockets in Gemfile. Here is my config.ru to serve assets:
require ::File.expand_path('../config/environment', __FILE__)
Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
load_paths << "app/assets/stylesheets"
load_paths << Compass::Frameworks['compass'].stylesheets_directory
load_paths << Compass::Frameworks['twitter_bootstrap'].stylesheets_directory
end
builder = Rack::Builder.new do
map '/assets' do
environment = Sprockets::Environment.new
environment.append_path 'app/assets/javascripts'
environment.append_path 'app/assets/stylesheets'
run environment
end
map '/' do
use Rack::FiberPool, :size => 250
run YourApp::Application
end
end
run builder
It needs to precompile assets in production. I will look on it later.