Apr
21
Tempfiles and very large multipart forms
Ignore the fact that problems with very large forms suggest a user interface refactoring is on the cards. When a form is multipart, the Ruby CGI module creates a Tempfile for many or all of the fields, which on some systems causes the process to die horribly emitting Last Words like:
Errno::EMFILE: Too many open files
This is a workaround that verges on a hack. Adding it to config/environment.rb in a Rails app at least allows one to proceed.
Process.setrlimit(Process::RLIMIT_NOFILE, 1024)
Brought to you by the Dept of Tuesday Morning Frustrations.