Skip to content

Fix COCO export timeouts with temp file approach#1529

Open
JasonWildMe wants to merge 10 commits intomainfrom
coco-timeout-fix
Open

Fix COCO export timeouts with temp file approach#1529
JasonWildMe wants to merge 10 commits intomainfrom
coco-timeout-fix

Conversation

@JasonWildMe
Copy link
Copy Markdown
Collaborator

Summary

  • Switches COCO export from direct-to-response streaming to a temp file model, preventing NGINX proxy timeout corruption on large exports
  • Writes ZIP to uploadTmpDir first, then streams the completed file with an accurate Content-Length header
  • Adds response.isCommitted() guard so error handling doesn't mix HTML into a partially-written ZIP stream
  • Fixes resource leaks in EncounterCOCOExportFile: HttpURLConnection disconnect in detectContentType(), Graphics2D disposal in convertAndWriteImage()
  • Ensures manifest consistency: images written first, JSON manifest references only successfully exported images

Root cause

The frontend fetch() call receives a TypeError: Failed to fetch when NGINX's proxy_read_timeout (default 60s) kills the connection while Tomcat is still streaming images into the ZIP. Tomcat doesn't detect the disconnect and logs success. The temp file decouples the slow image-fetching phase from the fast file-streaming phase.

Test plan

  • Export COCO on a dataset with 2000+ images — verify ZIP downloads completely without "Failed to fetch"
  • Verify temp file is cleaned up after download (check uploadTmpDir in container)
  • Confirm small exports (< 50 images) still work as before
  • Unit tests pass (EncounterCOCOExportFileTest)

🤖 Generated with Claude Code

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 11.82796% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.87%. Comparing base (55a2dc8) to head (152f6e3).

Files with missing lines Patch % Lines
...d/src/pages/SearchPages/components/ExportModal.jsx 11.82% 82 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1529      +/-   ##
==========================================
- Coverage   53.25%   52.87%   -0.39%     
==========================================
  Files         274      274              
  Lines        9818     9910      +92     
  Branches     2906     2931      +25     
==========================================
+ Hits         5229     5240      +11     
- Misses       4345     4426      +81     
  Partials      244      244              
Flag Coverage Δ
backend 52.87% <11.82%> (-0.39%) ⬇️
frontend 52.87% <11.82%> (-0.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JasonWildMe JasonWildMe requested a review from naknomum April 9, 2026 06:30
@JasonWildMe JasonWildMe self-assigned this Apr 9, 2026
@JasonWildMe JasonWildMe marked this pull request as draft April 9, 2026 06:31
@JasonWildMe JasonWildMe marked this pull request as ready for review April 13, 2026 18:08
@goddesswarship
Copy link
Copy Markdown
Contributor

@naknomum bumping for your review!

@naknomum naknomum added this to the 10.10.5 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants