Skip to content

[3.x] Fail fast when a package exceeds the AWS Lambda size limit - #460

Draft
mnapoli wants to merge 1 commit into
3.xfrom
package-size-check-3x
Draft

mnapoli wants to merge 1 commit into
3.xfrom
package-size-check-3x

Conversation

@mnapoli

@mnapoli mnapoli commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #459 to 3.x: same change, with the docs link pointing to the 3.x packaging guide.

Tested the same way. npm test passes (3511 tests, the only failure is an uncaught getRandomValues error on Node 26 that also happens without this change). The packaging integration tests and the large zip smoke test pass. On the real 305 MB service, serverless deploy fails in under a second with the new message, and a normal-size service still packages.

AWS Lambda rejects deployment packages larger than 250 MB once unzipped.
osls zipped and uploaded such packages anyway, and the deployment only
failed minutes later, when CloudFormation created the function:
"Unzipped size must be smaller than 262144000 bytes".

Add up the size of the files before zipping them and fail right away,
listing the largest top-level files and directories of the package and
pointing to `package.patterns`. This applies to service, function and
layer packages, for both `package` and `deploy`.

The check is skipped when a plugin overrides getFileContent() or
getFileContentAndStat(), as the zipped content can then differ from the
files on disk. Layers also count toward the limit, but the unzipped size
of external layers is not known locally: only packages that are too
large on their own are rejected.

Claude-Session: https://claude.ai/code/session_01Awk33iZ9mDSg1xgSAPkgGK
@mnapoli
mnapoli marked this pull request as draft September 27, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant