All skills
aws avatar

/aws-sdk-js-v3-usage

@c3ed514

AWS SDK for JavaScript v3 development patterns. Use when writing JavaScript or TypeScript code that uses AWS services via @aws-sdk/* packages (aws-sdk-js-v3), or when asked about schemas, runtime validation, serialization, or code generation in the context of the JS/TS AWS SDK.

Use this Skill: https://skilld.dev/gh/aws/agent-toolkit-for-aws/aws-sdk-js-v3-usage

This session only. Nothing lands on disk.

referencesperformance.md

≈495 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Performance Reference

Parallel Workloads (Node.js)

Socket Configuration

Set maxSockets to match your parallel batch size:

import { NodeHttpHandler } from "@aws-sdk/config/requestHandler";
import { Agent } from "node:https";

const client = new S3Client({
  cacheMiddleware: true, // cache middleware resolution — only if not adding custom middleware
  requestHandler: new NodeHttpHandler({
    httpsAgent: new Agent({ keepAlive: true, maxSockets: 50 }),
  }),
});

// Shorthand (v3.521.0+):
const client = new S3Client({
  requestHandler: { requestTimeout: 3_000, httpsAgent: { maxSockets: 50 } },
});

Too few sockets → queuing slowdown. Too many → new socket overhead + risk of EMFILE (too many open files).

Sharing Credentials and Socket Pool

const primary = new S3Client({ region: "us-east-1" });
const { credentials, requestHandler } = primary.config;
const secondary = new S3Client({ region: "us-west-2", credentials, requestHandler });

Streaming Deadlock

With limited sockets, don't await the request before setting up stream consumption:

// WRONG: deadlock with maxSockets: 1
const responses = await Promise.all([
  s3.getObject({ Bucket, Key: "1" }),
  s3.getObject({ Bucket, Key: "2" }),
]);
await Promise.all(responses.map((r) => r.Body.transformToByteArray()));

// OK: chain stream handling before awaiting
const responses = [s3.getObject({ Bucket, Key: "1" }), s3.getObject({ Bucket, Key: "2" })];
const objects = responses.map((get) => get.Body.transformToByteArray());
await Promise.all(objects);

Batch Upload Example

const BATCH_SIZE = 100;
const client = new S3Client({ requestHandler: { httpsAgent: { maxSockets: 100 } } });

const promises = [];
while (files.length) {
  promises.push(...files.splice(0, BATCH_SIZE).map((f) =>
    client.send(new PutObjectCommand({ Bucket: "b", Key: f.name, Body: f.contents }))
  ));
  await Promise.all(promises);
  promises.length = 0;
}

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a comprehensive documentation resource for the AWS SDK for JavaScript v3. It provides development patterns, best practices for credential management, resource handling, and performance optimization using official AWS packages and repositories.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at c3ed514. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 5 months ago

README badge

README badge for aws/agent-toolkit-for-aws/aws-sdk-js-v3-usage