npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@battleline/sqs-large-payload-nodejs

v2.0.0

Published

Transparently offload large SQS messages to S3 when they exceed the size limit

Readme

sqs-large-payload-nodejs

CI

Transparently offload large SQS messages to S3 when they exceed the size limit. Built for AWS SDK v3.

SQS has a maximum message size of 1 MiB. This library automatically uploads messages larger than that threshold to S3, and sends a lightweight reference through SQS instead. On the receiving side, it detects the reference and fetches the original payload from S3.

Installation

npm install @battleline/sqs-large-payload-nodejs @aws-sdk/client-sqs @aws-sdk/client-s3

Note: @aws-sdk/client-sqs and @aws-sdk/client-s3 are peer dependencies — you bring your own SDK v3 clients.

Quick Start

import { SqsLargePayloadService } from "@battleline/sqs-large-payload-nodejs";

const sqs = new SqsLargePayloadService({
  region: "us-east-2",
  s3BucketName: "my-payload-bucket",
  queueUrl: "https://sqs.us-east-2.amazonaws.com/123456789/my-queue",
});

// Send a message (automatically offloads to S3 if > 1 MiB)
const result = await sqs.sendMessage({ key: "value" });
console.log(result.messageId);

// Process a received message (transparently fetches from S3 if needed)
const body = await sqs.processReceivedMessage(event.Records[0].body);

API

new SqsLargePayloadService(options)

| Option | Type | Required | Default | Description | |---------------------|------------|----------|---------|-------------| | region | string | Yes | | AWS region | | s3BucketName | string | Yes | | S3 bucket for large payloads | | queueUrl | string | No | | SQS queue URL (preferred over queueName) | | queueName | string | No | | SQS queue name (resolved via GetQueueUrl) | | maxMessageSize | number | No | 1 MiB | Byte threshold for S3 offload | | s3DeleteAfterLoad | boolean | No | false | Delete S3 object after retrieval | | sqsClient | SQSClient| No | | Bring your own SQS client | | s3Client | S3Client | No | | Bring your own S3 client |

sendMessage<T>(body: T, queueNameOrUrl?: string): Promise<SendMessageOutput>

Serializes body to JSON and sends it to SQS. If the serialized size exceeds maxMessageSize, the payload is uploaded to S3 first and a reference is sent through SQS.

sendMessageBatch<T>(entries: SendMessageBatchEntry<T>[], queueNameOrUrl?: string): Promise<SendMessageBatchResultEntry[]>

Send up to 10 messages in a single batch. Each entry that exceeds the threshold is individually offloaded to S3.

processReceivedMessage(messageBody: string): Promise<string>

Pass in the raw SQS message body. If it contains an S3Payload reference, the original payload is fetched from S3 (and optionally deleted). Otherwise the message is returned as-is.

getQueueUrl(queueNameOrUrl?: string): Promise<string>

Resolve a queue name to a URL, or pass through a URL directly.

IAM Permissions

S3: s3:PutObject, s3:GetObject, s3:DeleteObject (only if s3DeleteAfterLoad: true)

SQS: sqs:GetQueueUrl, sqs:SendMessage, sqs:SendMessageBatch

Error Handling

The library throws typed errors:

  • MissingQueueError — no queue name or URL was provided
  • QueueUrlResolutionErrorGetQueueUrl returned no result
  • S3PayloadError — S3 upload or download failed
  • SqsLargePayloadError — base class for all errors above
import { S3PayloadError } from "@battleline/sqs-large-payload-nodejs";

try {
  await sqs.sendMessage(hugePayload);
} catch (err) {
  if (err instanceof S3PayloadError) {
    console.error("S3 issue:", err.cause);
  }
}

Migrating from v1

See CHANGELOG.md for the full migration guide.