Skip to content

chore: Include buffers (30MB) for SNS and SQS message payloads#408

Merged
Drodevbar merged 2 commits intomainfrom
chore/descrease-sns-message-max-size-threshold
Feb 26, 2026
Merged

chore: Include buffers (30MB) for SNS and SQS message payloads#408
Drodevbar merged 2 commits intomainfrom
chore/descrease-sns-message-max-size-threshold

Conversation

@Drodevbar
Copy link
Collaborator

@Drodevbar Drodevbar commented Feb 23, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Adjusted SNS and SQS outgoing message size calculations to reserve space for attributes/overhead, preventing oversized payloads.
    • Result: lower effective max body sizes (SNS ~226 KB, SQS ~994 KB) to improve delivery reliability.
  • Documentation

    • Clarified inline documentation explaining how message size limits are computed and applied.

@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

Replaced single fixed message-size constants with separate HARD_LIMIT and ATTRIBUTE_BUFFER constants and recalculated MESSAGE_MAX_SIZE for both SNS and SQS; updated inline docs to clarify that body size is measured and a reserved buffer accounts for attributes/overhead.

Changes

Cohort / File(s) Summary
SNS core
packages/sns/lib/sns/AbstractSnsService.ts
Added SNS_MESSAGE_HARD_LIMIT and SNS_MESSAGE_ATTRIBUTE_BUFFER; redefined SNS_MESSAGE_MAX_SIZE as SNS_MESSAGE_HARD_LIMIT - SNS_MESSAGE_ATTRIBUTE_BUFFER and added explanatory comments.
SNS utils
packages/sns/lib/utils/snsUtils.ts
Updated documentation for calculateOutgoingMessageSize to state body-only measurement and reference the reserved attribute/overhead buffer.
SQS core
packages/sqs/lib/sqs/AbstractSqsService.ts
Added SQS_MESSAGE_HARD_LIMIT and SQS_MESSAGE_ATTRIBUTE_BUFFER; redefined SQS_MESSAGE_MAX_SIZE as SQS_MESSAGE_HARD_LIMIT - SQS_MESSAGE_ATTRIBUTE_BUFFER with comments.
SQS utils
packages/sqs/lib/utils/sqsUtils.ts
Updated documentation for outgoing size calculation to clarify body-only sizing and the reserved buffer used to derive SQS_MESSAGE_MAX_SIZE.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Adjust SQS limits #403 — Modifies SQS message-size constants in packages/sqs/lib/sqs/AbstractSqsService.ts; closely related changes to SQS size limits.

Suggested labels

patch

Poem

🐰
A hop, a nibble, constants aligned,
Hard limits set, buffers assigned.
Body fits snug, attributes cheer,
Payloads safe, the burrow's clear. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions '30MB' buffers but the actual changes introduce much smaller buffers: 30KB for SNS and an unspecified amount for SQS, not 30MB. Update the title to accurately reflect the actual buffer sizes introduced (e.g., 'chore: Add buffer constants for SNS and SQS message size calculations') or include accurate buffer sizes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/descrease-sns-message-max-size-threshold

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Drodevbar Drodevbar requested a review from kibertoad February 23, 2026 16:32
@Drodevbar Drodevbar changed the title chore: Decrease SNS message max size threshold chore: Decrease SNS message max size threshold to 220KB Feb 23, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/sns/lib/sns/AbstractSnsService.ts`:
- Line 13: Update the comment on SNS_MESSAGE_MAX_SIZE to clearly state why the
220KB application limit was chosen (e.g., "conservative safety margin to reserve
~36KB for future message attributes and overhead" or "based on anticipated
average attribute payloads of X bytes") and make a matching note in the
message-size computation comment in snsUtils (the function that currently
computes size from the message body only) so it explicitly documents the
assumption and future work to include attributes; also call out that
SNS_MESSAGE_MAX_SIZE is re-exported from the public API and advise adding a
changelog note so downstream consumers expecting 256KB are informed.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97ca85f and e8d52e7.

📒 Files selected for processing (1)
  • packages/sns/lib/sns/AbstractSnsService.ts

@Drodevbar Drodevbar changed the title chore: Decrease SNS message max size threshold to 220KB chore: Include buffers (30MB) for SNS and SQS message payloads Feb 25, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/sqs/lib/sqs/AbstractSqsService.ts (1)

12-14: LGTM — minor optional nit on unit notation in comments.

AWS increased the SQS maximum message payload from 256 KiB to 1 MiB, so SQS_MESSAGE_HARD_LIMIT = 1024 * 1024 is correct. The decomposition into HARD_LIMIT and ATTRIBUTE_BUFFER cleanly mirrors the SNS approach described in the PR.

One optional nit: 30 * 1024 and the derived SQS_MESSAGE_MAX_SIZE are binary multiples (KiB), but the inline comments use "KB" (decimal). Consider aligning with "KiB" to match the established "1 MiB" annotation on line 12 and avoid ambiguity.

✏️ Optional comment nit
-export const SQS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30KB - reserved space for message attributes and overhead
-export const SQS_MESSAGE_MAX_SIZE = SQS_MESSAGE_HARD_LIMIT - SQS_MESSAGE_ATTRIBUTE_BUFFER // 994KB - maximum allowed message body size
+export const SQS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30 KiB - reserved space for message attributes and overhead
+export const SQS_MESSAGE_MAX_SIZE = SQS_MESSAGE_HARD_LIMIT - SQS_MESSAGE_ATTRIBUTE_BUFFER // 994 KiB - maximum allowed message body size
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/sqs/lib/sqs/AbstractSqsService.ts` around lines 12 - 14, Update the
unit notation in the inline comments to use binary units (KiB) to match the
existing "1 MiB" notation: change the comment on SQS_MESSAGE_ATTRIBUTE_BUFFER
(currently "30KB") to "30 KiB" and the comment on SQS_MESSAGE_MAX_SIZE
(currently "994KB") to "994 KiB", leaving the numeric constants and variable
names SQS_MESSAGE_HARD_LIMIT, SQS_MESSAGE_ATTRIBUTE_BUFFER, and
SQS_MESSAGE_MAX_SIZE unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/sqs/lib/sqs/AbstractSqsService.ts`:
- Around line 12-14: Update the unit notation in the inline comments to use
binary units (KiB) to match the existing "1 MiB" notation: change the comment on
SQS_MESSAGE_ATTRIBUTE_BUFFER (currently "30KB") to "30 KiB" and the comment on
SQS_MESSAGE_MAX_SIZE (currently "994KB") to "994 KiB", leaving the numeric
constants and variable names SQS_MESSAGE_HARD_LIMIT,
SQS_MESSAGE_ATTRIBUTE_BUFFER, and SQS_MESSAGE_MAX_SIZE unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8d52e7 and 5f98f79.

📒 Files selected for processing (4)
  • packages/sns/lib/sns/AbstractSnsService.ts
  • packages/sns/lib/utils/snsUtils.ts
  • packages/sqs/lib/sqs/AbstractSqsService.ts
  • packages/sqs/lib/utils/sqsUtils.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/sns/lib/utils/snsUtils.ts
  • packages/sqs/lib/utils/sqsUtils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sns/lib/sns/AbstractSnsService.ts

@Drodevbar Drodevbar merged commit 87b1614 into main Feb 26, 2026
13 checks passed
@Drodevbar Drodevbar deleted the chore/descrease-sns-message-max-size-threshold branch February 26, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants