Skip to content

fix: reuse S3 client and bound its timeout/retries - #70

Merged
samerzughul merged 1 commit into
mainfrom
muhannad/fix-s3-client-lifetime
Aug 25, 2026
Merged

fix: reuse S3 client and bound its timeout/retries#70
samerzughul merged 1 commit into
mainfrom
muhannad/fix-s3-client-lifetime

Conversation

@mmalkhatib

Copy link
Copy Markdown
Contributor

Summary

  • ICloudFilesService (S3 provider) was registered AddTransient, so CloudFilesService's constructor built a brand-new AmazonS3Client (fresh TCP+TLS handshake, no connection pooling) on every DI resolution. AmazonS3Client is documented by AWS as thread-safe and meant to be reused — registered as AddSingleton instead.
  • AmazonS3Config had no explicit Timeout/MaxErrorRetry, so it fell back to AWS SDK defaults (~100s timeout, several backoff retries on transient errors). Added Timeout = 15s and MaxErrorRetry = 2 so a genuine storage-endpoint hiccup fails fast instead of hanging for minutes.

Why now

Live production incident across multiple Traxis services today (invoice issuance with attachments, manual shipment/label creation) all timing out for ~1 minute then failing, recovering only after 2-3 retries — traced to every one of these services sharing this same client-construction pattern via AddS3CloudFiles().

Test plan

  • dotnet build SW.CloudFiles.sln succeeds clean
  • Bump SW.CloudFiles.S3/SW.CloudFiles.S3.Extensions PackageReference in affected Traxis services (Accounting, Ship, Gateway, ...) after this publishes, and confirm attachment/label calls no longer hang

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: simplify9/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d9750672-fcf0-4dd2-9c9c-f6f32a1f3413


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ICloudFilesService was registered AddTransient, so CloudFilesService's
constructor built a brand-new AmazonS3Client (fresh TCP+TLS handshake,
no connection pooling) on every DI resolution, with no explicit
Timeout/MaxErrorRetry so it fell back to the AWS SDK defaults (~100s
timeout, several backoff retries). Under any latency to the storage
endpoint this made calls hang for a long time before failing.

AmazonS3Client is documented as thread-safe and meant to be reused, so
register it as a singleton. Timeout/MaxErrorRetry are now configurable
via S3CloudFilesOptions.TimeoutSeconds/MaxErrorRetry (bound from the
CloudFiles config section, or set in the AddS3CloudFiles(options => ...)
delegate), defaulting to 15s/2 retries so a genuine outage fails fast
instead of retrying for minutes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mmalkhatib
mmalkhatib force-pushed the muhannad/fix-s3-client-lifetime branch from bdf2f5a to ecaa504 Compare August 25, 2026 11:07
@samerzughul
samerzughul merged commit d6be81e into main Aug 25, 2026
5 checks passed
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