feat: support concurrent chunk uploads#95
Conversation
Greptile SummaryThis PR upgrades the SDK's chunked file upload from a sequential loop to a concurrent pool (max 8 in-flight chunks), uploads the first chunk individually to obtain the server-assigned
Confidence Score: 3/5Safe to merge with caution — the concurrent upload logic works correctly in the happy path, but has an edge case where a chunk failure leaves orphaned server-side writes. The concurrent pool correctly serialises shared-counter updates thanks to JavaScript’s single-threaded event loop, and progress reporting is accurate. However, when any chunk rejects the outer promise, the pool’s bookkeeping leaves server-side upload state in an indeterminate position that can affect retries. src/client.ts — the new concurrent chunk upload pool in chunkedUpload() Important Files Changed
|
| if (totalChunks === 1) { | ||
| return response; | ||
| } | ||
|
|
||
| // Prepare remaining chunks |
There was a problem hiding this comment.
Dead code:
totalChunks === 1 can never be reached
The guard at line 977 already returns early whenever file.size <= Client.CHUNK_SIZE, which is exactly the condition that makes Math.ceil(file.size / CHUNK_SIZE) === 1. So by the time execution reaches this check, totalChunks is always ≥ 2 and this branch is unreachable. Remove it to avoid misleading future readers.
| if (totalChunks === 1) { | |
| return response; | |
| } | |
| // Prepare remaining chunks | |
| // Prepare remaining chunks |
|
Closing in favor of focused PR #96. |
This PR updates the SDK to support concurrent chunk uploads.