fix(export): send HTTP headers before serializing large exports - #721
Conversation
ActivityWatch#677 still wrote the full JSON tempfile before responding, so a ~500k-event export could sit silent until the 30s web UI timeout. Open a pipe, return 200 + Content-Disposition immediately, and serialize into the body. Missing buckets still 404 before headers. Mid-stream failures truncate the download instead of hanging the connection. ActivityWatch/aw-android#228 Git-Session-Id: a180614b-5a5a-5d29-84d8-e1c4e076b990
Review guide (auto-posted)Structured warm-up for reviewers — what changed, what to run, where to look. Key files
Suggested verification
Known risks / watch points
Suggested review focus
Generated by |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #721 +/- ##
==========================================
+ Coverage 70.81% 79.85% +9.03%
==========================================
Files 51 75 +24
Lines 2916 8404 +5488
==========================================
+ Hits 2065 6711 +4646
- Misses 851 1693 +842 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Serialize to a tempfile on the worker (disk-paced, same as ActivityWatch#677), then copy to the response pipe from the export thread. Headers still go out before the body; unread or slow downloads no longer block heartbeats. ActivityWatch/aw-android#228 Git-Session-Id: 3f22e322-f840-50e9-aa06-6db541c7f001
|
@greptileai review |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
Why
HTTP JSON exports still wait until serialization finishes before sending headers (
#677writes a tempfile first). A ~500k-event export then hits the web UI's 30s axios timeout and looks like a no-op. Same on desktop.ActivityWatch/aw-android#228
Companion PRs:
Change
200+Content-DispositionimmediatelyMid-stream failures truncate the download instead of hanging the connection. Event buffering stays bounded (same serializer as
#677).Tests
cargo test -p aw-server --test api export— existing round-trip/header tests plus empty all-buckets filename.