Async Rails 3.1 资产问题

发布于 2024-12-02 19:29:32 字数 1265 浏览 4 评论 0原文

我在异步 Rails 3.1 应用程序上遇到资产问题,我设法构建了一个最小的示例来显示我的问题,但它对我没有多大帮助。

该应用程序非常简单,我所做的是: - 使用 3.1 创建一个新的应用程序(非 rc) - 添加thin+Rack::FiberPool - 设置波本威士忌(scss mixins) - 运行应用程序

现在我用“rails server Thin”启动一台服务器,之后任何请求都将在“堆栈级别太深”中结束,只有一个回溯行:/

这是最小的应用程序:https://github.com/schmurfy/assets_crash

这是我在执行请求时得到的回溯: http://dl.dropbox.com/u/1313066/github/crash_assets.png

我试图深入了解问题所在,导致我进入文件 template_handlers.rb 中的 sass-rails:

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

我尝试使用 Pry 进行探索( irb 替代方案),我发现的更令人费解:在 binding.pry 行时,我可以触发堆栈级别太深:

{}.merge(:anything => Resolver.new(scope))

结果是立即的,但我在该对象中找不到任何可以解释结果的内容。

任何线索都会受到欢迎。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

背叛残局 2024-12-09 19:29:32

我终于找到了答案: Fiber 只有 4Kb 的堆栈空间,而 Ruby on Rails 现在太大了,无法容纳这个空间:/

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 :/

时常饿 2024-12-09 19:29:32

我遇到了同样的问题,将我的 ruby​​ 升级到 1.9.3-preview1 并从头开始构建了所有的 gem,现在一切正常。

编辑:
好吧,再玩一会儿之后,看起来确实是 Rack::Fiberpool 导致了这个问题。当我将 Rack::Fiberpool 插入 Rails 堆栈后,它又回来了...

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...

情深缘浅 2024-12-09 19:29:32

禁用 Rails 中的资产管道。不需要 sass-rails,而是需要 Gemfile 中的 sass 和 sprocket。这是我的 config.ru 来提供资产:

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

它需要在生产中预编译资产。我稍后会看一下。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文