Add Lambda tests for large response handling by dominikschubert · Pull Request #10229 · localstack/localstack · GitHub
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Add Lambda tests for large response handling#10229

Merged
joe4dev merged 7 commits into
masterfrom
investigate-lambda-response-size
Feb 13, 2024
Merged

Add Lambda tests for large response handling#10229
joe4dev merged 7 commits into
masterfrom
investigate-lambda-response-size

Conversation

@dominikschubert

@dominikschubert dominikschubert commented Feb 13, 2024

Copy link
Copy Markdown
Member

Motivation

We didn't really cover the case where the returned response from the lambda handler is over the defined 6MB limit and received issue reports that this lead to the functions being in a broken state and timing out instead of properly failing immediately.

Changes

  • Add a test for a large but still valid response
  • Add a test for a response that is over the limit and thus fails
  • Add config LAMBDA_LIMITS_MAX_FUNCTION_PAYLOAD_SIZE_BYTES to modify the maximum payload size & corresponding test
  • Update lambda init version to v0.1.27-pre

TODO

@dominikschubert dominikschubert self-assigned this Feb 13, 2024
@dominikschubert dominikschubert added the semver: patch Non-breaking changes which can be included in patch releases label Feb 13, 2024
@github-actions

github-actions Bot commented Feb 13, 2024

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Feb 13, 2024

Copy link
Copy Markdown

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 21m 12s ⏱️ - 1m 58s
2 640 tests +5  2 393 ✅ +5  247 💤 ±0  0 ❌ ±0 
2 642 runs  +5  2 393 ✅ +5  249 💤 ±0  0 ❌ ±0 

Results for commit 9029548. ± Comparison against base commit 3cce93c.

♻️ This comment has been updated with latest results.

@dominikschubert dominikschubert force-pushed the investigate-lambda-response-size branch from 0b79a41 to 83edf96 Compare February 13, 2024 13:26
@dominikschubert dominikschubert marked this pull request as ready for review February 13, 2024 15:04
@dominikschubert dominikschubert marked this pull request as draft February 13, 2024 15:05
@dominikschubert dominikschubert force-pushed the investigate-lambda-response-size branch from 83edf96 to d0b1e7d Compare February 13, 2024 15:10

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tests look good 👍

just nits not blocking a merge

Comment thread localstack/config.py Outdated
)
# SEMI-PUBLIC: not actively communicated
LAMBDA_LIMITS_MAX_FUNCTION_PAYLOAD_SIZE_BYTES = int(
os.environ.get("LAMBDA_LIMITS_MAX_FUNCTION_PAYLOAD_SIZE_BYTES", 6 * 1024 * 1024 + 100)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FYI: There are even more different quotes: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
just in case we run into these in the future ...

6 MB each for request and response (synchronous)

20 MB for each streamed response (Synchronous. The payload size for streamed responses can be increased from default values. Contact AWS Support to inquire further.)

256 KB (asynchronous)

Comment thread tests/aws/services/lambda_/test_lambda.py
Comment thread tests/aws/services/lambda_/test_lambda.py Outdated
Comment thread tests/aws/services/lambda_/functions/lambda_response_size.py Outdated
Comment thread tests/aws/services/lambda_/test_lambda.py
Comment thread localstack/config.py Outdated
Comment thread tests/aws/services/lambda_/test_lambda.py Outdated
@dominikschubert dominikschubert marked this pull request as ready for review February 13, 2024 16:09

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

(missed another json.loads 😅 )

)
snapshot.match("invoke_result", result)

# second invoke to make sure we didn't break further invocations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice extra sanity check 👍

Comment thread tests/aws/services/lambda_/test_lambda.py Outdated

@dfangl dfangl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@coveralls

Copy link
Copy Markdown

@joe4dev joe4dev merged commit 7b9fd2c into master Feb 13, 2024
@joe4dev joe4dev deleted the investigate-lambda-response-size branch February 13, 2024 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants