Skip to content

feat: support concurrent chunk uploads#174

Merged
TorstenDittmann merged 1 commit into
mainfrom
concurrent-chunk-uploads-1-9-x-minimal
May 21, 2026
Merged

feat: support concurrent chunk uploads#174
TorstenDittmann merged 1 commit into
mainfrom
concurrent-chunk-uploads-1-9-x-minimal

Conversation

@TorstenDittmann
Copy link
Copy Markdown
Contributor

This PR updates the Web SDK to support concurrent chunk uploads.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR rewrites the chunked upload path in src/client.ts to dispatch up to 8 chunks concurrently after uploading the first chunk sequentially to obtain the upload ID, and adds setKey and setForwardedUserAgent helpers along with a version bump to 25.2.0.

  • The concurrent upload orchestration (first-chunk sequencing, shared rejected/completedCount state, and Promise-based concurrency gate) is correct for JavaScript's single-threaded execution model and should work reliably against Appwrite's synchronous server-side assembly.
  • ping() return type was widened from Promise<string> to Promise<unknown>, which is a breaking TypeScript API change for consumers that typed the return value.
  • finalResponse ?? lastResponse relies on isUploadComplete firing for the assembled-file response; if it doesn't (edge-case server behavior), the returned value is the chronologically last chunk response, which is non-deterministic in concurrent mode.

Confidence Score: 5/5

The concurrent upload logic is structurally sound; the two new observations are cosmetic or edge-case concerns that do not affect normal operation.

The core concurrency change is correct: first chunk is uploaded sequentially to get the upload ID, remaining chunks are dispatched with an in-flight cap, shared counters are safe under JS's single-threaded model, and failure propagation is handled cleanly. The two findings are a type-widening regression in ping() and a defensive fallback that only matters if the server returns an unexpected response shape.

src/client.ts — the isUploadComplete predicate and finalResponse ?? lastResponse fallback are worth a second look to confirm they match the server's actual response shape for assembled files.

Important Files Changed

Filename Overview
src/client.ts Adds concurrent chunk uploads (up to 8 in-flight), setKey/setForwardedUserAgent helpers, and flips x-sdk-platform to 'server'; the concurrent upload logic is sound for the happy path but has an edge-case non-deterministic fallback return value when isUploadComplete never fires.
package.json Version bump from 25.1.1 to 25.2.0, no other changes.
package-lock.json Lock-file version bump to match package.json, no dependency changes.

Reviews (2): Last reviewed commit: "feat: support concurrent chunk uploads" | Re-trigger Greptile

Comment thread src/client.ts
Comment thread src/client.ts
Comment thread src/client.ts
Comment thread src/client.ts
@TorstenDittmann
Copy link
Copy Markdown
Contributor Author

Note for reviewers: the normal cloud sdks task currently cannot generate sdk-for-web as a client SDK because CE config lists web under APP_SDK_PLATFORM_SERVER, and the generator sets x-sdk-platform from the enclosing platform key via setPlatform($key). Generating through that path produces server-only drift like x-sdk-platform: server, API key headers, forwarded user agent, and server ping behavior. This Web SDK update should be generated with explicit platform=client output so the package remains the browser/client SDK.

@TorstenDittmann
Copy link
Copy Markdown
Contributor Author

@greptile-apps please review this PR again.

@TorstenDittmann TorstenDittmann merged commit f14cf39 into main May 21, 2026
3 checks passed
@TorstenDittmann TorstenDittmann deleted the concurrent-chunk-uploads-1-9-x-minimal branch May 21, 2026 18:57
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.

2 participants