Skip to content

feat(event-handler): warn when AppSync Events payload exceeds 240 KB per-event limit#5339

Merged
dreamorosi merged 3 commits into
mainfrom
feat/appsync-events-warn-large-payload
Jun 12, 2026
Merged

feat(event-handler): warn when AppSync Events payload exceeds 240 KB per-event limit#5339
dreamorosi merged 3 commits into
mainfrom
feat/appsync-events-warn-large-payload

Conversation

@dreamorosi

Copy link
Copy Markdown
Contributor

Summary

Changes

Adds an opt-in warnOnLargePayload option to the AppSyncEventsResolver. When enabled, the resolver emits a warn log whenever an individual event in the response exceeds the AWS AppSync Events per-event size limit of 240 KB (including the event id).

Events larger than this limit are silently dropped by AppSync and never delivered to subscribers, which is hard to diagnose. This gives customers a way to detect the problem before messages are lost.

Details:

  • New warnOnLargePayload flag on RouterOptions, disabled by default (measuring size requires serializing each event, which has a cost on large batches).
  • Works in both per-event and aggregate modes, since the limit applies per event regardless of how the handler is invoked.
  • The check measures the assembled { id, payload } item with Buffer.byteLength(JSON.stringify(...)) so it reflects what AppSync sees on the wire (including the id, which the library injects in non-aggregate mode and the customer cannot otherwise measure).
  • Warnings are deduplicated once per channel path to avoid log spam.

This implements the outcome discussed in the issue: a warning rather than a public getSize() (which cannot see the library-injected id in non-aggregate mode) or a post-publish hook.

Tests and documentation (new "Detecting oversized events" section + snippet) are included.

Issue number: closes #4020


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L PRs between 100-499 LOC label Jun 12, 2026
@dreamorosi dreamorosi marked this pull request as draft June 12, 2026 12:59
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L PRs between 100-499 LOC and removed size/L PRs between 100-499 LOC labels Jun 12, 2026
@dreamorosi dreamorosi marked this pull request as ready for review June 12, 2026 14:01
@dreamorosi dreamorosi requested a review from svozza June 12, 2026 14:02
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L PRs between 100-499 LOC and removed size/L PRs between 100-499 LOC labels Jun 12, 2026
@sonarqubecloud

Copy link
Copy Markdown

@dreamorosi dreamorosi merged commit 2e7850d into main Jun 12, 2026
39 checks passed
@dreamorosi dreamorosi deleted the feat/appsync-events-warn-large-payload branch June 12, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L PRs between 100-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Calculate AppSync Event publish size before returning a response

2 participants