You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Single-file request download reads the whole file into memory when the client stops reading #500
Found while fixing #490 (multi-file zip downloads, PR #498).
A request with a single file downloads it directly (GET /api/requests/[id]/download, the single-file branch in src/app/api/requests/[id]/download/route.ts). The response reads the file as fast as the disk allows and queues every chunk, whether or not the client is reading (fileStream.on('data', chunk => controller.enqueue(chunk)) never checks desiredSize).
A client that reads one chunk and then pauses for 3 seconds: the server has already read and queued the whole 100 MB test file.
So a paused or slow download of a large single-file book (for example a multi-GB m4b) holds the whole file in server memory until the client finishes or disconnects.
Multi-file zip downloads get the fix in PR #498. Single files need the same kind of change: a pull-based stream (Readable.toWeb on the file stream, or a pull() source) so the server reads only as fast as the client, and a cancel that closes the file.
Activity
fix: a single-file download reads the file only as fast as the client…