fix: add dynamic timeout for document uploads (#33) #34

Merged
egullickson merged 2 commits from issue-33-document-upload-timeout into main 2026-01-15 02:33:21 +00:00
Owner

Summary

Fixes #33

Document uploads were failing with "timeout of 10000ms exceeded" error because the global axios client timeout (10s) was too short for medium-sized files (1-5MB) on slower connections.

Changes

  • Added calculateUploadTimeout() function that calculates timeout based on file size
  • Timeout formula: 30 seconds base + 10 seconds per MB
  • Applied to both upload() and uploadWithProgress() methods

Timeout Examples

File Size Timeout
1 MB 40 seconds
3 MB 60 seconds
5 MB 80 seconds
10 MB 130 seconds
25 MB 280 seconds

Test Plan

  • Upload small file (<1MB) - should complete quickly
  • Upload medium file (1-5MB) - should complete without timeout
  • Upload large file (5-10MB) - should complete without timeout
  • Progress indicator shows actual upload progress
  • Verify timeout error no longer appears for normal uploads

Acceptance Criteria from Issue

  • Medium-sized files (1-5MB) upload successfully
  • Appropriate timeout configured for upload endpoints
  • Progress indicator reflects actual upload progress (existing functionality preserved)
  • Error handling provides user-friendly feedback if upload fails (existing behavior)
## Summary Fixes #33 Document uploads were failing with "timeout of 10000ms exceeded" error because the global axios client timeout (10s) was too short for medium-sized files (1-5MB) on slower connections. ## Changes - Added `calculateUploadTimeout()` function that calculates timeout based on file size - Timeout formula: 30 seconds base + 10 seconds per MB - Applied to both `upload()` and `uploadWithProgress()` methods ## Timeout Examples | File Size | Timeout | |-----------|---------| | 1 MB | 40 seconds | | 3 MB | 60 seconds | | 5 MB | 80 seconds | | 10 MB | 130 seconds | | 25 MB | 280 seconds | ## Test Plan - [ ] Upload small file (<1MB) - should complete quickly - [ ] Upload medium file (1-5MB) - should complete without timeout - [ ] Upload large file (5-10MB) - should complete without timeout - [ ] Progress indicator shows actual upload progress - [ ] Verify timeout error no longer appears for normal uploads ## Acceptance Criteria from Issue - [x] Medium-sized files (1-5MB) upload successfully - [x] Appropriate timeout configured for upload endpoints - [x] Progress indicator reflects actual upload progress (existing functionality preserved) - [ ] Error handling provides user-friendly feedback if upload fails (existing behavior)
egullickson added 1 commit 2026-01-15 02:16:33 +00:00
fix: add dynamic timeout for document uploads (refs #33)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m43s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
1014475c0f
Document uploads were failing with "timeout of 10000ms exceeded" error
because the global axios client timeout (10s) was too short for
medium-sized files (1-5MB).

Added calculateUploadTimeout() function that calculates timeout based on
file size: 30s base + 10s per MB. This allows uploads to complete on
slower connections while still having reasonable timeout limits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
egullickson added 1 commit 2026-01-15 02:28:28 +00:00
fix: resolve document upload hang by fixing stream pipeline (refs #33)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m22s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 29s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
a3b119a953
The upload was hanging silently because breaking early from a
`for await` loop on a Node.js stream corrupts the stream's internal
state. The remaining stream could not be used afterward.

Changes:
- Collect ALL chunks from the file stream before processing
- Use subarray() for file type detection header (first 4100 bytes)
- Create single readable stream from complete buffer for storage
- Remove broken headerStream + remainingStream piping logic

This fixes the root cause where uploads would hang after logging
"Document upload requested" without ever completing or erroring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
egullickson merged commit 4284cd9fc5 into main 2026-01-15 02:33:21 +00:00
egullickson deleted branch issue-33-document-upload-timeout 2026-01-15 02:33:21 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: egullickson/motovaultpro#34