Rails: creating/updating 条记录时出现 EOF 错误
Rails: EOF Error when creating/updating a record
我最近偶然发现了我的 rails 应用程序的问题。
我正在使用 ruby 2.1.0 和 Rails 3.2.7(我知道),最近,当我 create/update 任何模型的任何记录时,我得到 EOFError - bad content body:
错误我的应用程序。一切似乎都在数据库级别工作,因为如果我重新加载,可以看到更改(如果我创建一条新记录,它会显示在列表视图中,如果我更新一条记录,则会反映更改)。
这是 rails 服务器的踪迹:
EOFError - bad content body:
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:83:in `block in fast_forward_to_first_boundary'
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:81:in `fast_forward_to_first_boundary'
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:17:in `parse'
(gem) rack-1.4.7/lib/rack/multipart.rb:25:in `parse_multipart'
(gem) rack-1.4.7/lib/rack/request.rb:336:in `parse_multipart'
(gem) rack-1.4.7/lib/rack/request.rb:201:in `POST'
(gem) actionpack-3.2.7/lib/action_dispatch/http/request.rb:231:in `POST'
(gem) actionpack-3.2.7/lib/action_dispatch/http/parameters.rb:10:in `parameters'
(gem) actionpack-3.2.7/lib/action_dispatch/http/filter_parameters.rb:33:in `filtered_parameters'
(gem) actionpack-3.2.7/lib/action_controller/metal/instrumentation.rb:21:in `process_action'
(gem) actionpack-3.2.7/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
(gem) activerecord-3.2.7/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
(gem) actionpack-3.2.7/lib/abstract_controller/base.rb:121:in `process'
(gem) actionpack-3.2.7/lib/abstract_controller/rendering.rb:45:in `process'
(gem) actionpack-3.2.7/lib/action_controller/metal.rb:203:in `dispatch'
(gem) actionpack-3.2.7/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
(gem) actionpack-3.2.7/lib/action_controller/metal.rb:246:in `block in action'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:36:in `call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:600:in `call'
(gem) omniauth-1.4.2/lib/omniauth/strategy.rb:186:in `call!'
(gem) omniauth-1.4.2/lib/omniauth/strategy.rb:164:in `call'
(gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
(gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
(gem) rack-1.4.7/lib/rack/etag.rb:23:in `call'
(gem) rack-1.4.7/lib/rack/conditionalget.rb:25:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/head.rb:14:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/flash.rb:242:in `call'
(gem) rack-1.4.7/lib/rack/session/abstract/id.rb:210:in `context'
(gem) rack-1.4.7/lib/rack/session/abstract/id.rb:205:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/cookies.rb:338:in `call'
(gem) activerecord-3.2.7/lib/active_record/query_cache.rb:64:in `call'
(gem) activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:405:in `_run__451408873423695737__call__1903216192202827668__callbacks'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:84:in `protected_app_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:79:in `better_errors_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:56:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
(gem) railties-3.2.7/lib/rails/rack/logger.rb:26:in `call_app'
(gem) railties-3.2.7/lib/rails/rack/logger.rb:16:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/request_id.rb:22:in `call'
(gem) rack-1.4.7/lib/rack/methodoverride.rb:21:in `call'
(gem) rack-1.4.7/lib/rack/runtime.rb:17:in `call'
(gem) activesupport-3.2.7/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
(gem) rack-1.4.7/lib/rack/lock.rb:15:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/static.rb:62:in `call'
/home/oscar/.asdf/installs/ruby/2.1.0/lib/ruby/gems/2.1.0/bundler/gems/raven-ruby-16a463b59142/lib/raven/integrations/rack.rb:54:in `call'
(gem) railties-3.2.7/lib/rails/engine.rb:479:in `call'
(gem) railties-3.2.7/lib/rails/application.rb:220:in `call'
(gem) rack-1.4.7/lib/rack/content_length.rb:14:in `call'
(gem) railties-3.2.7/lib/rails/rack/log_tailer.rb:17:in `call'
(gem) thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
(gem) thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
(gem) thin-1.4.1/lib/thin/connection.rb:53:in `process'
(gem) thin-1.4.1/lib/thin/connection.rb:38:in `receive_data'
(gem) eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
(gem) thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
(gem) thin-1.4.1/lib/thin/server.rb:159:in `start'
(gem) rack-1.4.7/lib/rack/handler/thin.rb:13:in `run'
(gem) rack-1.4.7/lib/rack/server.rb:268:in `start'
(gem) railties-3.2.7/lib/rails/commands/server.rb:70:in `start'
(gem) railties-3.2.7/lib/rails/commands.rb:55:in `block in <top (required)>'
(gem) railties-3.2.7/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `<main>'
有人遇到过这样的问题吗?
问题可以找到here:
issue中有很多解决问题的建议。对我有用的是这个:
module Rack
module Multipart
class << self
alias_method :original_parse_multipart, :parse_multipart
def parse_multipart(env)
begin
original_parse_multipart(env)
rescue EOFError => e
nil
end
end
end
end
end
我不是很喜欢它,因为它只是忽略了问题,并没有指出错误的来源。
我最近偶然发现了我的 rails 应用程序的问题。
我正在使用 ruby 2.1.0 和 Rails 3.2.7(我知道),最近,当我 create/update 任何模型的任何记录时,我得到 EOFError - bad content body:
错误我的应用程序。一切似乎都在数据库级别工作,因为如果我重新加载,可以看到更改(如果我创建一条新记录,它会显示在列表视图中,如果我更新一条记录,则会反映更改)。
这是 rails 服务器的踪迹:
EOFError - bad content body:
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:83:in `block in fast_forward_to_first_boundary'
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:81:in `fast_forward_to_first_boundary'
(gem) rack-1.4.7/lib/rack/multipart/parser.rb:17:in `parse'
(gem) rack-1.4.7/lib/rack/multipart.rb:25:in `parse_multipart'
(gem) rack-1.4.7/lib/rack/request.rb:336:in `parse_multipart'
(gem) rack-1.4.7/lib/rack/request.rb:201:in `POST'
(gem) actionpack-3.2.7/lib/action_dispatch/http/request.rb:231:in `POST'
(gem) actionpack-3.2.7/lib/action_dispatch/http/parameters.rb:10:in `parameters'
(gem) actionpack-3.2.7/lib/action_dispatch/http/filter_parameters.rb:33:in `filtered_parameters'
(gem) actionpack-3.2.7/lib/action_controller/metal/instrumentation.rb:21:in `process_action'
(gem) actionpack-3.2.7/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
(gem) activerecord-3.2.7/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
(gem) actionpack-3.2.7/lib/abstract_controller/base.rb:121:in `process'
(gem) actionpack-3.2.7/lib/abstract_controller/rendering.rb:45:in `process'
(gem) actionpack-3.2.7/lib/action_controller/metal.rb:203:in `dispatch'
(gem) actionpack-3.2.7/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
(gem) actionpack-3.2.7/lib/action_controller/metal.rb:246:in `block in action'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:36:in `call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:600:in `call'
(gem) omniauth-1.4.2/lib/omniauth/strategy.rb:186:in `call!'
(gem) omniauth-1.4.2/lib/omniauth/strategy.rb:164:in `call'
(gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
(gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
(gem) rack-1.4.7/lib/rack/etag.rb:23:in `call'
(gem) rack-1.4.7/lib/rack/conditionalget.rb:25:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/head.rb:14:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/flash.rb:242:in `call'
(gem) rack-1.4.7/lib/rack/session/abstract/id.rb:210:in `context'
(gem) rack-1.4.7/lib/rack/session/abstract/id.rb:205:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/cookies.rb:338:in `call'
(gem) activerecord-3.2.7/lib/active_record/query_cache.rb:64:in `call'
(gem) activerecord-3.2.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:405:in `_run__451408873423695737__call__1903216192202827668__callbacks'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
(gem) activesupport-3.2.7/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:84:in `protected_app_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:79:in `better_errors_call'
(gem) better_errors-0.7.2/lib/better_errors/middleware.rb:56:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
(gem) railties-3.2.7/lib/rails/rack/logger.rb:26:in `call_app'
(gem) railties-3.2.7/lib/rails/rack/logger.rb:16:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/request_id.rb:22:in `call'
(gem) rack-1.4.7/lib/rack/methodoverride.rb:21:in `call'
(gem) rack-1.4.7/lib/rack/runtime.rb:17:in `call'
(gem) activesupport-3.2.7/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
(gem) rack-1.4.7/lib/rack/lock.rb:15:in `call'
(gem) actionpack-3.2.7/lib/action_dispatch/middleware/static.rb:62:in `call'
/home/oscar/.asdf/installs/ruby/2.1.0/lib/ruby/gems/2.1.0/bundler/gems/raven-ruby-16a463b59142/lib/raven/integrations/rack.rb:54:in `call'
(gem) railties-3.2.7/lib/rails/engine.rb:479:in `call'
(gem) railties-3.2.7/lib/rails/application.rb:220:in `call'
(gem) rack-1.4.7/lib/rack/content_length.rb:14:in `call'
(gem) railties-3.2.7/lib/rails/rack/log_tailer.rb:17:in `call'
(gem) thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
(gem) thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
(gem) thin-1.4.1/lib/thin/connection.rb:53:in `process'
(gem) thin-1.4.1/lib/thin/connection.rb:38:in `receive_data'
(gem) eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
(gem) thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
(gem) thin-1.4.1/lib/thin/server.rb:159:in `start'
(gem) rack-1.4.7/lib/rack/handler/thin.rb:13:in `run'
(gem) rack-1.4.7/lib/rack/server.rb:268:in `start'
(gem) railties-3.2.7/lib/rails/commands/server.rb:70:in `start'
(gem) railties-3.2.7/lib/rails/commands.rb:55:in `block in <top (required)>'
(gem) railties-3.2.7/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `<main>'
有人遇到过这样的问题吗?
问题可以找到here:
issue中有很多解决问题的建议。对我有用的是这个:
module Rack
module Multipart
class << self
alias_method :original_parse_multipart, :parse_multipart
def parse_multipart(env)
begin
original_parse_multipart(env)
rescue EOFError => e
nil
end
end
end
end
end
我不是很喜欢它,因为它只是忽略了问题,并没有指出错误的来源。