Skip to content

Conversation

@ndg63276
Copy link
Collaborator

JIRA ticket: LIMS-1275

Summary:

Large files can cause the server to run out of memory. Use a streamed response instead of loading the whole file into memory when unzipping.

Changes:

  • Don't set a memory limit as that was a bandaid
  • Don't set the content length header as Symfony deals with that automatically
  • Unzip and send 8kb of the file at a time, flushing from PHP's buffer and from the web server's buffer each time

To test:

  • Go to any data collection with an AutoProc result (eg /dc/visit/cm40607-5/id/20430060)
  • Click the Logs & Files button, then find the summary_inlined.html file, this is usually pretty large
  • Check the View button loads the file into a frame, and the Download button loads the file into the browser tab
  • Zip the file, keeping but renaming the original (to preserve permissions), and check it now downloads the zipped file, then undo the renaming after, eg
gzip -k summary_inlined.html
mv summary_inlined.html summary_inlined.original
# test Synchweb still works as expected
mv summary_inlined.original summary_inlined.html
rm summary_inlined.html.gz
  • Check the downloaded zipped file is valid and contains the expected file

Co-authored-by: Guilherme Francisco <guilherme.de-freitas@diamond.ac.uk>
@ndg63276 ndg63276 changed the base branch from master to pre-release/2025-R5.4 December 9, 2025 10:21
@ndg63276 ndg63276 merged commit 5e6f76b into pre-release/2025-R5.4 Dec 9, 2025
2 checks passed
@ndg63276 ndg63276 deleted the improvement/LIMS-1275/stream-files branch December 9, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants