---
title: Troubleshooting Serverless Package Too Large Errors
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Serverless > Serverless Monitoring Guides > Troubleshooting Serverless
  Package Too Large Errors
---

# Troubleshooting Serverless Package Too Large Errors

This guide helps you troubleshoot the error "Code uncompressed size is greater than max allowed size of 272629760". This error is most commonly seen when instrumenting Node.js serverless applications using the Datadog serverless plugin. The troubleshooting strategy may also apply to the same error if you see it for other languages or deployment methods.

The error indicates that your function's *uncompressed* code size exceeds the 250 MB limit. Both your [function package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html#gettingstarted-package-zip) (the `.zip` artifact containing your function code and dependencies) and the [Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html#gettingstarted-package-layers) configured on your function count towards this limit. Examine both to find the root cause.

## Layers{% #layers %}

Typically Datadog adds two Lambda layers for instrumentation:

- A language-specific library that instruments the function code, and
- The extension, which aggregates, buffers, and forwards observability data to the Datadog backend.

Inspect the content and size of the Datadog Lambda layers using AWS CLI command [`aws lambda get-layer-version`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/get-layer-version.html). For example, running the following commands gives you links to download the Lambda layers for _Datadog-Node24-x version 137 and _Datadog-Extension version 94 and inspect the uncompressed size (about 30 MB combined). The uncompressed size varies by layers and versions. Replace the layer name and version number in the following example with those used by your applications:

```
aws lambda get-layer-version \
  --layer-name arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node24-x \
  --version-number 137

aws lambda get-layer-version \
  --layer-name arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension \
  --version-number 94
```

In addition to the Datadog Lambda layers, also inspect other Lambda layers added (or to be added) to your functions. If you use the [Serverless Framework](https://www.serverless.com/), you can find the CloudFormation template from the hidden `.serverless` folder after running the `deploy` or `package` command, and the list of Lambda layers from the `Layers` section.

## Package{% #package %}

The function deployment package can contain large files or code that you don't need. If you use the Serverless Framework, you can find the generated deployment package (`.zip` file) in the hidden `.serverless` folder after running the `deploy` or `package` command.

If the sum of the size of the deployment package and layers doesn't exceed the limit, contact AWS Support for investigation. If the total size does exceed the limit, inspect the deployment package and exclude large files that you don't need in runtime using the [package](https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#package) option.

## Dependencies{% #dependencies %}

The Datadog Lambda layer packages the instrumentation libraries and makes them available to use in the Lambda execution environment, so you do *not* need to specify `datadog-lambda-js` and `dd-trace` as dependencies in your `package.json`. If you do need the Datadog libraries for local build or tests, specify them as `devDependencies` so that they are excluded from the deployment package. Similarly, `serverless-plugin-datadog` is needed only for development, and should be specified under `devDependencies`.

Also inspect other dependencies (the `node_modules` folder) that are included into your deployment package and only keep the ones that you need in `dependencies`.

## Bundlers{% #bundlers %}

Using a bundler like [Webpack](https://webpack.js.org) or [esbuild](https://esbuild.github.io/) can dramatically reduce your deployment package size by only including the code that is used. See [Node.js Lambda Tracing and Bundlers Compatibility](https://docs.datadoghq.com/serverless/guide/serverless_tracing_and_bundlers/) for required webpack configurations.

## Datadog-ci{% #datadog-ci %}

Depending on your use case, you may find it easier to use the `datadog-ci lambda instrument` command to work around issues with package sizes. The `datadog-ci lambda instrument` command configures the same instrumentation as serverless-plugin-datadog. For more information, see the [datadog-ci repo](https://github.com/DataDog/datadog-ci/tree/master/packages/plugin-lambda#readme).

## Get help{% #get-help %}

If you need the Datadog support team to help investigate, include the following information in your ticket:

1. The function's configured Lambda layers (name and version, or ARNs).
1. The function's deployment package (or a screenshot showing the content and size of the uncompressed package) to be uploaded to AWS.
1. The project configuration files, with **redacted hardcoded secrets**: `serverless.yaml`, `package.json`, `package-lock.json`, `yarn.lock`, `tsconfig.json` and `webpack.config.json`.

## Further Reading{% #further-reading %}

- [Instrumenting Node.js Applications](https://docs.datadoghq.com/serverless/installation/nodejs)
