fix(lambda): honor MaximumBatchingWindowInSeconds on SQS event source mappings (#3203)

* fix(lambda): honor MaximumBatchingWindowInSeconds on SQS event source mappings

CreateEventSourceMapping, GetEventSourceMapping and UpdateEventSourceMapping now
parse, validate (0 to 300), persist and return MaximumBatchingWindowInSeconds
instead of silently dropping it.

When the window is greater than 0 the SQS poller holds an underfilled batch open,
accumulating messages across polls, and invokes the function once the batch
reaches BatchSize or the window elapses since the first buffered message. A window
of 0 or unset keeps the previous invoke-on-first-receive behavior.

Closes #3155

* fix(lambda): cover the batching window in SQS message visibility and window-off transitions

Address review feedback on the batching-window poller:

- Visibility timeout is now fn.timeout + window + 30 instead of the max of the two,
  so a message buffered for the full window and then processed for the full
  function timeout stays invisible for the whole span. Otherwise a long invoke
  could outlive the visibility and another consumer would receive a duplicate
  with a stale receipt handle.
- When the window is changed from positive to zero (or unset) on a live mapping,
  the poller now drains and delivers any already-buffered batch on the next tick
  instead of ignoring it, so those messages are not stranded until their
  visibility expires and cannot be replayed alongside fresh copies if a positive
  window is later restored.
This commit is contained in:
Vũ Thế Huy authored and GitHub committed 2026-09-07 21:43:06 -05:00
1 parent 53a84c8890
commit ec2d678e6d
8 files changed
+350 -5

No files matched your search

+23
View File
@@ -737,6 +737,29 @@ aws lambda create-event-source-mapping \
--endpoint-url $AWS_ENDPOINT_URL
```
### MaximumBatchingWindowInSeconds (SQS)
`CreateEventSourceMapping` and `UpdateEventSourceMapping` accept a
`MaximumBatchingWindowInSeconds` integer between 0 and 300. `GetEventSourceMapping`
and `ListEventSourceMappings` echo it back when set; responses omit the field when
it was never configured. Values outside 0 to 300 are rejected with
`InvalidParameterValueException`.
When the window is greater than 0, the SQS poller holds an underfilled batch open,
accumulating messages across polls, and invokes the function once the batch reaches
`BatchSize` or the window elapses since the first buffered message, whichever comes
first. A window of 0 (or an unset window) invokes as soon as any message is
available, which is the previous behaviour.
```bash
aws lambda create-event-source-mapping \
--function-name my-function \
--event-source-arn $QUEUE_ARN \
--batch-size 10 \
--maximum-batching-window-in-seconds 5 \
--endpoint-url $AWS_ENDPOINT_URL
```
### ScalingConfig (SQS only)
`CreateEventSourceMapping` and `UpdateEventSourceMapping` accept a