Closed gaurijo closed 1 year ago
I think your diagnosis is correct, that ActionController can't handle returned Enumerators anymore, but this change adds an xml_data
array (in memory) which accumulates strings in memory and then sends out a joined string. The problem is that, depending on what the user is exporting, there may be hundreds of thousands of strings that take up more memory than is available to our ECS containers. For example, a full XML export may consume > 3GB.
I have pushed a different, memory-safe fix for this as 725eec4.
I have also opened #32 and #33.
This PR handles issue #29
Issue: When a user clicks on the
Export
link and chooses'MARCXML'
to download book record(s) a500 Internal Server Error
is thrown.Screenshot of error on local server:
The error was traced to the
index action
inside theBooks Controller
, particularly the use ofEnumerator
class inside theformat.xml do
code block. For some reason using Enumerator as a response body made Rails expect the object(s) to respond to.each
, which threw aNoMethodError
. Swapping out the Enumerator for the use of traditional response headers fixed the error.Screencast with fixed changes: (note: my local version doesn't have any book objects so it populates an empty list of book records, but still goes through the download process and should work the same with book objects present)
https://github.com/medusa-project/book-tracker/assets/103534307/dee848c4-22d4-4c23-ac8d-d3ec9ed2ee74
Rails server terminal output: