Error on deploy: xdn-deploy-lambda: Unzipped size

error - DeployBuild job failed [unexpected]: Error in xdn-deploy-lambda: Unzipped size must be smaller than 262144000 bytes

Fails during deployment. Build and run works fine locally.

As the error states, there is an upper limit on how big a package can be when deployed to our serverless infrastructure. Some common strategies for solving:

  • If you are running Nuxt, you may need to move some dependencies as described here only dependencies are copied up to the lambda.
  • Make sure you are using imports in a smart way. A common example is changing import {get} from lodash to import { get} from lodash/get to avoid unnecessary bloat in your modules
  • Make sure you are minifying your javascript during your build. In next.js you can add config.optimization.minimize = true; to your next.config.js

You can view what is included in your package under .xdn/lambda/ after a build, and running du -h -d 1 on the directories in a shell will output the size of each directory and help you identify where space savings can be found, ie du -h -d 1 .xdn/lambda/.next/serverless/pages

1 Like

@patrick.saweikis I’m interested in what library overran the limit in this specific case. Generally Next.js does a very good job of keeping the serverless build small. It can be a bit more challenging in Nuxt, but I’m surprised that you ran into this issue with a Next.js app.