fix: reuse S3 client and bound its timeout/retries - #70
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: simplify9/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 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. Comment |
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
force-pushed
the
muhannad/fix-s3-client-lifetime
branch
from
August 25, 2026 11:07
bdf2f5a to
ecaa504
Compare
samerzughul
approved these changes
Aug 25, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ICloudFilesService(S3 provider) was registeredAddTransient, soCloudFilesService's constructor built a brand-newAmazonS3Client(fresh TCP+TLS handshake, no connection pooling) on every DI resolution.AmazonS3Clientis documented by AWS as thread-safe and meant to be reused — registered asAddSingletoninstead.AmazonS3Confighad no explicitTimeout/MaxErrorRetry, so it fell back to AWS SDK defaults (~100s timeout, several backoff retries on transient errors). AddedTimeout = 15sandMaxErrorRetry = 2so 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.slnsucceeds cleanSW.CloudFiles.S3/SW.CloudFiles.S3.ExtensionsPackageReference in affected Traxis services (Accounting, Ship, Gateway, ...) after this publishes, and confirm attachment/label calls no longer hang🤖 Generated with Claude Code