Conversation
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
marked this pull request as draft
September 27, 2026 10:15
Contributor
|
Is this MiB or MB. AWS Regularly typo this in their docs and write MB when they actually mean MiB. In the code you write MB but the calculations use MiB. |
Contributor
|
262144000 bytes looks like 250MiB to me, not 250MB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AWS Lambda rejects deployment packages larger than 250 MB once unzipped. Today osls zips and uploads such a package anyway, and
osls deployonly fails when CloudFormation creates the function, several minutes later, with a raw AWS error:The error doesn't say what is large or how to fix it, and a failed first deployment also leaves a rolled back stack behind.
This PR adds up the size of the files right before zipping them (the stats were already collected) and fails immediately when the package reaches the limit:
individually) and layer packages, during bothosls packageandosls deploy, before any AWS call, and nothing is zipped.getFileContent()orgetFileContentAndStat(), because the zipped content can then differ from the files on disk.What about the 50 MB zipped limit? It only applies to code uploaded directly through the Lambda API.
osls deployuploads artifacts to S3 and CloudFormation references them, so only the 250 MB unzipped limit applies. (osls deploy functiondoes upload the zip directly withUpdateFunctionCode, so it is still subject to the 50 MB limit. This PR doesn't change that.)Testing
zipFiles()rejects withPACKAGE_TOO_LARGEand the exact message, and no artifact is left behind.osls packageandosls deployfail in under a second with the message above. The same service packages normally oncepackage.patternsexcludes enough files (185 MB left). A function packaged individually and a layer above the limit are rejected too.npm testpasses (except 2 Pythoninvoke localtests that also fail without this change on my machine),npm run integration-test-run-packagepasses, the large zip smoke test passes, and prettier and eslint are clean.Backport of #<4.x PR> to 3.x: same change, with the docs link pointing to the 3.x packaging guide.
Tested the same way.
npm testpasses (3511 tests, the only failure is an uncaughtgetRandomValueserror 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 deployfails in under a second with the new message, and a normal-size service still packages.