@aws-sdk/client-s3
semver
^3.0.0postconditions18functions9last verified2026-06-23coverage score91%Postconditions: what we check
- send · s3-object-operation-no-try-catcherrorWhens3Client.send() called with object operation commands without try-catchThrows
NoSuchKey (404), AccessDenied (403), NoSuchBucket (404), network errorsRequired handlingMUST wrap await s3Client.send() in try-catch block when using GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, or CopyObjectCommand. Catch block should check error.name for specific error types (NoSuchKey, AccessDenied, NoSuchBucket) and handle appropriately.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - send · s3-multipart-no-try-catcherrorWhens3Client.send() called with multipart commands without try-catchThrows
NoSuchUpload (404), EntityTooSmall (400), InvalidPart (400)Required handlingMUST wrap multipart upload operations in try-catch block. Catch block MUST call AbortMultipartUploadCommand with the uploadId to clean up orphaned parts. This prevents storage charges for incomplete uploads.costhighin prodsilent failureusers seelost datavisibilitysilentSources[2] - send · s3-bucket-operation-no-try-catcherrorWhens3Client.send() called with bucket operations without try-catchThrows
BucketAlreadyExists (409), BucketNotEmpty (409), NoSuchBucket (404)Required handlingMUST wrap bucket operations in try-catch block. Handle BucketAlreadyExists/BucketAlreadyOwnedByYou gracefully (may be acceptable), check BucketNotEmpty before deletion, validate permissions.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - send · s3-list-operation-no-try-catchwarningWhens3Client.send() called with list operations without try-catchThrows
NoSuchBucket (404), AccessDenied (403), InvalidArgument (400)Required handlingSHOULD wrap list operations in try-catch block for robustness. Handle NoSuchBucket and AccessDenied errors gracefully. Implement pagination properly with ContinuationToken.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - S3Client · s3-client-no-retry-configinfoWhenS3Client created without retry configurationRequired handlingCONSIDER configuring retry settings: new S3Client({ region, maxAttempts: 3, retryMode: 'adaptive' }). Adaptive mode adjusts retry attempts based on throttling signals from AWS.costlowin proddegraded serviceusers seedegraded performancevisibilityvisibleSources[4]
- S3Client · s3-client-missing-regionwarningWhenS3Client created without explicit regionRequired handlingSHOULD explicitly set region: new S3Client({ region: 'us-east-1' }) or use environment variable with fallback.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1]
- DeleteObjectsCommand · s3-batch-delete-errors-not-checkederrorWhens3Client.send(DeleteObjectsCommand) is called and the response.Errors array is not checked after the await resolvesThrows
S3ServiceException (for auth/request failures); individual object errors are in response.Errors[]Required handlingMUST check response.Errors after every DeleteObjectsCommand call. If response.Errors && response.Errors.length > 0, handle each failed key individually. Do not assume all objects were deleted just because the command did not throw.costhighin prodsilent failureusers seelost datavisibilitysilentSources[5] - DeleteObjectsCommand · s3-batch-delete-quiet-mode-uncheckedwarningWhenDeleteObjectsCommand is called with Delete.Quiet: true and response.Errors is not checked after the awaitThrows
response.Errors[] contains deletion failures (not thrown)Required handlingSHOULD check response.Errors even in Quiet mode. If response.Errors has entries, log failed keys and handle appropriately. Consider using verbose mode (Quiet: false) in non-performance-critical paths to get full deletion confirmation.costmediumin prodsilent failureusers seelost datavisibilitysilentSources[5] - waitUntilObjectExists · s3-waiter-timeout-not-handlederrorWhenwaitUntilObjectExists() is called without a try-catch block and the object does not appear within maxWaitTime secondsThrows
TimeoutError (error.name === 'TimeoutError') from @smithy/util-waiterRequired handlingMUST wrap waitUntilObjectExists in try-catch. Check error.name === 'TimeoutError' to distinguish timeout from other failures. Return a meaningful error to the caller rather than propagating the raw TimeoutError.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - waitUntilObjectExists · s3-waiter-abort-not-handledwarningWhenwaitUntilObjectExists() is called with an AbortSignal and the signal is triggered before the waiter completes, without try-catch handling AbortErrorThrows
AbortError (error.name === 'AbortError') from @smithy/util-waiterRequired handlingSHOULD handle AbortError separately from TimeoutError in catch block. AbortError means intentional cancellation; TimeoutError means capacity issue. Treat AbortError as a clean cancellation, not a failure.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - waitUntilBucketExists · s3-bucket-waiter-timeout-not-handlederrorWhenwaitUntilBucketExists() is called without a try-catch block and the bucket does not become accessible within maxWaitTime secondsThrows
TimeoutError (error.name === 'TimeoutError') from @smithy/util-waiterRequired handlingMUST wrap waitUntilBucketExists in try-catch. Handle TimeoutError by retrying with increased maxWaitTime or surfacing a meaningful error. Do not assume bucket creation is always fast — cross-region propagation adds latency.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - AbortMultipartUploadCommand · s3-abort-multipart-no-try-catcherrorWhens3Client.send(AbortMultipartUploadCommand) is called without try-catch, especially inside a catch block of a failed multipart upload flowThrows
NoSuchUpload (404) when UploadId is invalid, expired, or already completedRequired handlingMUST wrap AbortMultipartUploadCommand in try-catch when used in cleanup paths. Handle NoSuchUpload gracefully (the upload may have already been cleaned up). Log the abort failure but do not let it mask the original error.costmediumin prodsilent failureusers seelost datavisibilitysilentSources[6] - AbortMultipartUploadCommand · s3-abort-multipart-in-flight-partswarningWhenAbortMultipartUploadCommand is called once without verifying all parts are freed, when concurrent part uploads may still be in flightThrows
S3 does not throw — parts may remain and incur storage charges silentlyRequired handlingSHOULD call ListPartsCommand after AbortMultipartUpload to verify all parts are freed. If parts remain, retry the abort. This prevents ongoing storage charges for abandoned upload parts.costmediumin prodsilent failureusers seelost datavisibilitysilentSources[6] - RestoreObjectCommand · s3-restore-object-no-try-catcherrorWhens3Client.send(RestoreObjectCommand) is called without try-catchThrows
ObjectAlreadyInActiveTierError (409) when object is in active tier; RestoreAlreadyInProgress (409) when restore is already runningRequired handlingMUST wrap RestoreObjectCommand in try-catch. Handle ObjectAlreadyInActiveTierError gracefully (object is already accessible, no restore needed). Handle RestoreAlreadyInProgress as informational (check restore status before retrying).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[7] - RestoreObjectCommand · s3-restore-expedited-unavailablewarningWhenRestoreObjectCommand is called with GlacierJobParameters.Tier: 'Expedited' without fallback handling for capacity unavailabilityThrows
GlacierExpeditedRetrievalNotAvailable (503) when expedited capacity is insufficientRequired handlingSHOULD catch GlacierExpeditedRetrievalNotAvailable and retry with Tier: "Standard" as fallback. Do not surface expedited-specific errors to end users — fall back silently to Standard tier.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[7] - waitUntilObjectNotExists · s3-object-not-exists-waiter-timeout-not-handlederrorWhenwaitUntilObjectNotExists() is called without a try-catch block and the object remains visible past maxWaitTime secondsThrows
TimeoutError (error.name === 'TimeoutError') from @smithy/util-waiterRequired handlingMUST wrap waitUntilObjectNotExists in try-catch. Check error.name === 'TimeoutError' to distinguish timeout from other failures. Surface a meaningful error to the caller (e.g. "object still visible after N seconds — manual verification required") rather than propagating the raw TimeoutError. Do not silently swallow — that hides eventual-consistency issues from operators.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - waitUntilObjectNotExists · s3-object-not-exists-waiter-abort-not-handledwarningWhenwaitUntilObjectNotExists() is called with an AbortSignal and the signal is triggered before the waiter completes, without try-catch handling AbortErrorThrows
AbortError (error.name === 'AbortError') from @smithy/util-waiterRequired handlingSHOULD handle AbortError separately from TimeoutError in catch block. AbortError means intentional cancellation (treat as clean cancellation, not a failure). TimeoutError means the object did not disappear in time (treat as eventual-consistency lag — surface to operator).costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - waitUntilBucketNotExists · s3-bucket-not-exists-waiter-timeout-not-handlederrorWhenwaitUntilBucketNotExists() is called without a try-catch block and the bucket remains visible past maxWaitTime secondsThrows
TimeoutError (error.name === 'TimeoutError') from @smithy/util-waiterRequired handlingMUST wrap waitUntilBucketNotExists in try-catch. Handle TimeoutError by retrying with increased maxWaitTime or surfacing an operator-visible error. Do not silently swallow — leaked buckets accrue storage costs and may cause naming collisions in CI test runs.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
Sources
Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.
Official documentation
- [1]docs.aws.amazon.com/AWSJavaScriptSDK/v3/latestS3
- [2]docs.aws.amazon.com/AmazonS3/latest/userguideMpuoverview
- [3]docs.aws.amazon.com/AmazonS3/latest/APIErrorResponses
- [4]docs.aws.amazon.com/sdk-for-javascript/v3/developer-guideError Handling
- [5]docs.aws.amazon.com/AWSJavaScriptSDK/v3/latestDeleteObjectsCommand
- [6]docs.aws.amazon.com/AWSJavaScriptSDK/v3/latestAbortMultipartUploadCommand
- [7]docs.aws.amazon.com/AWSJavaScriptSDK/v3/latestRestoreObjectCommand
Source code
- [8]github.com/smithy-lang/smithy-typescript/blobsmithy-lang/smithy-typescript · waiter.ts
Research notes
Curator notes from SOURCES.md captured when the profile was written so you can verify the reasoning, not just the rules.
Sources for @aws-sdk/client-s3 Nark profile
Official Documentation
AWS SDK for JavaScript v3 - S3 Client
- URL: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
- Relevance: Primary API reference for S3Client and command patterns
- Key Points:
- All S3 operations use command pattern:
client.send(new Command(params)) - Common errors: NoSuchKey, AccessDenied, NoSuchBucket
- Multipart uploads require cleanup on failure
- All S3 operations use command pattern:
Error Handling Best Practices
- URL: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/error-handling.html
- Relevance: SDK error handling patterns
- Key Points:
- Service errors are thrown exceptions
- Check
error.$metadatafor request details - Retry logic for transient failures
S3 Multipart Upload
- URL: https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html
- Relevance: Multipart upload lifecycle and cleanup requirements
- Key Points:
- Must abort incomplete uploads to avoid storage charges
- UploadPart failures should trigger AbortMultipartUpload
Common Error Scenarios
NoSuchKey (404)
- Occurs when object doesn't exist
- Should be handled explicitly in application logic
NoSuchBucket (404)
- Bucket doesn't exist or incorrect region
- Critical error requiring bucket creation
AccessDenied (403)
- Insufficient IAM permissions
- Should be logged and surfaced to user
Network Errors
- Connection timeouts, DNS failures
- Should implement retry logic with exponential backoff
Severity Rationale
ERROR Level
- Object Operations: Data loss or corruption if errors not handled
- Multipart Uploads: Resource leaks without proper cleanup
- Bucket Operations: Infrastructure state inconsistencies
WARNING Level
- List Operations: Less critical, pagination handles most edge cases
- Generally safe to fail without corrupting state
Need a different package?
Request a profile