Skip to content

fix(drive): correct S3 presign region, push download status over socket - #360

Merged
safwansamsudeen merged 1 commit into
developfrom
fix/drive-download-followups
Jul 28, 2026
Merged

fix(drive): correct S3 presign region, push download status over socket#360
safwansamsudeen merged 1 commit into
developfrom
fix/drive-download-followups

Conversation

@safwansamsudeen

Copy link
Copy Markdown
Collaborator

Summary

  • generate_presigned_url signs offline and never gets boto3's automatic region-redirect retry that a real S3 call gets. Signed against the client's default region, S3 rejected the URL outright with PermanentRedirect for any bucket outside that region — hit in prod, since drive.frappe.cloud lives in ap-south-1 and the client defaulted to us-east-1. Each bucket's real region is now detected via get_bucket_location (itself region-agnostic) and cached, and presigning uses a client that matches.
  • Replaces the 2s download_status poll with a single socket subscription: build_download_archive publishes the terminal ready/failed state to the requesting user's realtime room, and the client just listens (with one immediate status check as a race guard for a build finishing before the listener attaches, plus the existing timeout as a fallback if the event is ever dropped).
  • Swaps the manual "preparing" toast for frappe-ui's toast.promise — one loading toast that morphs into success/error in place instead of hand-tracking an id across separate toast() calls.

Builds on #359 (already merged) — this branch is off develop.

Test plan

  • Verified the region bug and fix live against prod's ap-south-1 bucket via bench console (get_bucket_location + region-scoped presign)
  • Download a folder locally end-to-end: confirm the "Preparing download…" toast appears once, updates in place to "Download prepared", and the archive downloads
  • Force a build failure (e.g. delete the source file mid-build) and confirm the toast shows the error instead of hanging
  • Confirm no more download_status polling in the network tab — only one socket event drives completion

🤖 Generated with Claude Code

- generate_presigned_url signs offline, so it never gets the automatic
  region-redirect retry a real S3 call gets — signed against the
  client's default region, S3 rejects the URL outright with
  PermanentRedirect for any bucket outside that region (hit in prod:
  drive.frappe.cloud lives in ap-south-1, client defaulted to
  us-east-1). Detect and cache each bucket's real region via
  get_bucket_location (itself region-agnostic) and sign with a client
  that matches.
- replace the 2s download_status poll with a single socket
  subscription: build_download_archive now publishes the terminal
  ready/failed state to the requesting user's realtime room, and the
  client just listens (with one immediate status check as a race
  guard for a build finishing before the listener attaches, and the
  existing timeout as a fallback if the event is ever dropped).
- swap the manual "preparing" toast for frappe-ui's toast.promise —
  one loading toast that morphs into success/error in place, instead
  of hand-tracking an id across two separate toast() calls.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@safwansamsudeen
safwansamsudeen merged commit 6b1af8b into develop Jul 28, 2026
4 checks passed
@safwansamsudeen
safwansamsudeen deleted the fix/drive-download-followups branch July 28, 2026 07:31
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.

1 participant