Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails CookieOverflow

Suddenly, in my first Rails app, I've started seeing this error:

/!\ FAILSAFE /!\  Fri Sep 11 17:30:48 -0400 2009
Status: 500 Internal Server Error
ActionController::Session::CookieStore::CookieOverflow

A little research points to the usage of of cookies to store session data, but I'm not doing that (at least not intentionally). Moreover, this just started happening today. The only thing I've started working on today is the ability to upload a zip file. The zip file that I'm trying to use for testing is 1.1MB.

Additionally, Firebug shows only 2 cookies for this domain. The one named _html_session is 507B and the one named user_credentials is 147B. Are uploaded files temporarily stored in such a way that a large-ish file could be causing this? Uploading a single image works just fine.

Thanks for your help.

UPDATE: Oops. Contrary to my comments to Vitaly and xijo below, the error is not quite instant. In this case I'm uploading something to my Image model and the error is happening when my ImagesController calls @image.save!.

What's interesting is that I still don't really understand where the error happens. I created an Image#before_validation method and raising an exception there, but the CookieOverflow error happens before I ever get there. Is there any place I can drop code after the controller makes the save call and before that particular callback? My understanding is that before_validation is the first callback.

like image 314
Rob Wilkerson Avatar asked Sep 11 '09 21:09

Rob Wilkerson


3 Answers

This can easily happen if you try and store a flash[:notice] = 'blah' message that is too long, since that message is stored in the session cookie.

like image 118
Matt Connolly Avatar answered Nov 06 '22 20:11

Matt Connolly


I just ran into a similar problem today. Apparently, Rails sessions can only store 4k of data. One possible solution it to use a database store for your sessions.

To do this:

  1. Add config.action_controller.session_store = :active_record_store to your environment.rb file.
  2. Create a migration file for your sessions using rake db:sessions:create
  3. Run the migration rake db:migrate

Hope this helps

like image 36
Buzzy Avatar answered Nov 06 '22 19:11

Buzzy


the only thing that comes to mind is that you somehow did put your .zip into the session.

To debug it:

  • add 'require "ruby-debug"' to your environment.rb
  • find the place where it prints the error message and put a 'debugger' there.
  • run it and it will stop when it hits the 'debugger' command
  • examine the call stack to see if there is anything relevant.
  • examine the session at that point in time. see what exactly takes the space there.
like image 3
Vitaly Kushner Avatar answered Nov 06 '22 21:11

Vitaly Kushner