I am often get ActionDispatch::Cookies::CookieOverflow
error on heroku in my rails application.
I think dumping unused information in session like
env["airbrake.error_id"] = notify_airbrake(e)
could be problem.
I have dumped many strings into the session, maybe that could be the problem.
I read some post which suggests that this could be because of activeadmin
also.
finally i thought of creating a sessions table as suggested here
I am unable to figure out what would be the best approach to solve this issue? Please suggest all possible solutions.
Code in my config/initializers/session_store.rb
Demo::Application.config.session_store :cookie_store, key: '_demo_appplication', :domain => :all
By airbrake i get this stacktrace of error
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:471:in []=
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/session/cookie_store.rb:110:in set_cookie
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:350:in commit_session
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:226:in context
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:560:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/query_cache.rb:36:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in block in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:82:in run_callbacks
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:27:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/remote_ip.rb:76:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in call_app
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in block in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in block in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:26:in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in tagged
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/static.rb:64:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/skip_binary.rb:19:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/deflater.rb:25:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/serve_zipped_assets.rb:50:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/dragonfly-1.0.5/lib/dragonfly/cookie_monster.rb:9:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/font_assets-0.1.11/lib/font_assets/middleware.rb:29:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/engine.rb:514:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:144:in call
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in public_send
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in method_missing
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in process_client
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in worker_loop
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in spawn_missing_workers
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in start
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in <top (required)>
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in load
[PROJECT_ROOT]/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in <main>
Rails cookies are limited to 4KB. Note that the session is stored in the cookie in the default configuration too. See: http://guides.rubyonrails.org/security.html#session-storage
The only thing you can do about that: Do not store big objects in the cookie. Store them in the database and then only store the object's id
in the cookie.
This answer might also be interesting to you: https://stackoverflow.com/a/4604212/2483313
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With