
Aws Sdk Js V3 Usage
Configure AWS SDK for JavaScript v3 clients with sane HTTP timeouts, socket pools, retries, and browser vs Node handlers without guessing Smithy defaults.
Overview
AWS SDK JS v3 Usage is an agent skill for the Build phase that documents Client configuration for AWS SDK for JavaScript v3—HTTP handlers, timeouts, sockets, retries, and browser vs Node setup.
Install
npx skills add https://github.com/aws/agent-toolkit-for-aws --skill aws-sdk-js-v3-usageWhat is this skill?
- Node shorthand and explicit NodeHttpHandler examples with requestTimeout and connectionTimeout
- Documents default maxSockets per client and socket-enqueue capacity warnings
- Browser FetchHttpHandler vs XhrHttpHandler for upload progress events
- maxAttempts and ConfiguredRetryStrategy patterns for custom backoff
- keepAlive and httpsAgent tuning to reduce connection churn
- Default maxSockets is 50 per client
Adoption & trust: 1.2k installs on skills.sh; 819 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your AWS v3 clients hang, exhaust sockets, or retry wrong because defaults and @smithy handler options are unclear from scattered docs.
Who is it for?
Solo builders integrating AWS from TypeScript or JavaScript who hit enqueue warnings or need upload progress in the browser.
Skip if: Teams only using AWS CDK or CLI with no application SDK code, or Python/boto3 stacks.
When should I use this skill?
Configuring AWS SDK for JavaScript v3 service clients for Node.js or browser applications.
What do I get? / Deliverables
You configure S3 and other service clients with explicit timeouts, pooling, and retry strategies matched to Node or browser runtimes.
- Client configuration snippets
- Retry and HTTP handler setup
- Runtime-specific handler import map
Recommended Skills
Journey fit
SDK client tuning happens while wiring AWS calls into your app or agent backend, before you stress-test shipping paths. Backend is where S3, DynamoDB, and other service clients need requestHandler, maxSockets, and retry strategy choices that affect reliability under load.
How it compares
Configuration reference for @aws-sdk v3 clients—not a tutorial for IAM policy design or full serverless architecture.
Common Questions / FAQ
Who is aws-sdk-js-v3-usage for?
JavaScript and TypeScript developers using modular AWS SDK v3 in Node or the browser who need correct requestHandler and retry setup.
When should I use aws-sdk-js-v3-usage?
During Build when creating S3/Dynamo clients, fixing socket capacity warnings, or choosing Fetch vs Xhr handlers for browser uploads.
Is aws-sdk-js-v3-usage safe to install?
It is documentation-only patterns; check the Security Audits panel on this page and keep AWS credentials in env or IAM roles, never in generated snippets.
SKILL.md
READMESKILL.md - Aws Sdk Js V3 Usage
# Client Configuration Reference ## Request Handler (HTTP) ### Node.js (shorthand, v3.521.0+) ```js const client = new S3Client({ requestHandler: { requestTimeout: 15_000, // ms to receive response connectionTimeout: 6_000, // ms to establish connection httpsAgent: { keepAlive: true, maxSockets: 50 }, }, }); ``` ### Node.js (explicit) ```js import { NodeHttpHandler } from "@smithy/node-http-handler"; import https from "node:https"; const client = new S3Client({ requestHandler: new NodeHttpHandler({ httpsAgent: new https.Agent({ keepAlive: true, maxSockets: 200 }), requestTimeout: 15_000, connectionTimeout: 6_000, }), }); ``` Default `maxSockets` is 50 per client. Socket exhaustion warning: ```text @smithy/node-http-handler:WARN - socket usage at capacity=N and M additional requests are enqueued. ``` ### Browser ```js import { FetchHttpHandler } from "@aws-sdk/config/requestHandler"; const client = new S3Client({ requestHandler: new FetchHttpHandler({ requestTimeout: 30_000 }) }); ``` XHR (for upload progress events): ```js import { XhrHttpHandler } from "@aws-sdk/xhr-http-handler"; const handler = new XhrHttpHandler({ requestTimeout: 30_000 }); handler.on(XhrHttpHandler.EVENTS.UPLOAD_PROGRESS, (event) => { ... }); const client = new S3Client({ requestHandler: handler }); ``` ## Retry Strategy ```js // Simple: set max attempts new S3Client({ maxAttempts: 5 }); // Custom backoff import { ConfiguredRetryStrategy } from "@aws-sdk/config/retryStrategy"; new S3Client({ retryStrategy: new ConfiguredRetryStrategy(5, (attempt) => 500 + attempt * 1_000), }); // Adaptive (rate-limiting) new S3Client({ retryMode: "ADAPTIVE" }); ``` When `retryStrategy` is set, `retryMode` and `maxAttempts` are ignored. ## Logging ```js // Enable SDK logging (suppress trace/debug) new S3Client({ logger: { ...console, debug() {}, trace() {} }, }); ``` For full request/response logging, use middleware (see SKILL.md Middleware section). ## Endpoint ```js // Custom endpoint (e.g. local mock) new S3Client({ endpoint: "http://localhost:8888" }); ``` ## FIPS / Dual-stack ```js new S3Client({ useFipsEndpoint: true }); new S3Client({ useDualstackEndpoint: true }); ``` ## Retrieving the Endpoint Without Making a Request **This interface is not public/stable.** Do not use in production, or verify it on every SDK version upgrade. ```ts import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3"; import { getEndpointFromInstructions } from "@smithy/middleware-endpoint"; const client = new S3Client({ region: "us-east-1" }); /** @internal do not directly use in production. */ const endpoint = await getEndpointFromInstructions( { Key: "foo", Bucket: "bar" }, // 1. command input GetObjectCommand, // 2. Command class client.config // 3. client config ); ``` ## Protocol Selection (v3.953.0+) Most services support only one protocol. CloudWatch and SQS support multiple: ```js import { AwsJson1_0Protocol, AwsSmithyRpcV2CborProtocol } from "@aws-sdk/core/protocols"; new CloudWatch({ protocol: AwsJson1_0Protocol }); // default new CloudWatch({ protocol: AwsSmithyRpcV2CborProtocol }); // CBOR ``` ## Middleware Caching ```js // Cache middleware stack per client+command — reduces per-request overhead. // Do not use if you modify the middleware stack after requests begin. new S3Client({ cacheMiddleware: true }); ``` ## S3-Specific Options ```js // Retry with corrected region on 301 redirect (use only if bucket region is unknown) new S3Client({ followRegionRedirects: true }); ``` ## Schemas (v3.953.0+) See `references/schemas.md`. # Credentials Reference All providers from `@aws-sdk/credential-providers`. ## Provider Quick Reference | Provider | Use case | |---|---| | `fromNodeProviderChain()` | Default Node.js chain (env → ini → IMDS/ECS) | | `fromEnv()` | `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` env vars | | `fromIni()` | `~/.aws/credentials` / `~/