#nestjsswagger + serverless-plugin-datadog + serverless-layers weird incompatibility

2 messages · Page 1 of 1 (latest)

rose briar
#

When the following is installed and enabled the project doesn't work when deployed to aws lambda

  1. serverless-layers
  2. serverless-plugin-datadog
  3. @nestjs/swagger

if you disable any of them everything works fine (except the disabled portion ofc)

More info in https://github.com/Shereef/nestjs-swagger-serverless-layers-datadog-issue/blob/main/README.md

To test this out

  1. Add DATADOG_API_KEY env var with your datadog env vars
  2. Add AWS key id and secret to your env vars AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY
  3. run npm i
  4. run npx serverless deploy --verbose
  5. visit the url from the console output

It should display swagger but it doesn't instead {"message": "Internal server error"}

see bottom of https://github.com/Shereef/nestjs-swagger-serverless-layers-datadog-issue/blob/main/README.md full output

if you append /v1 to the url it should show Hello World! but it doesn't

i.e. https://qwerty.execute-api.us-east-2.amazonaws.com/dev/ should show swagger
i.e. https://qwerty.execute-api.us-east-2.amazonaws.com/dev/v1 should show Hello World!

The three above combined break the lambda function

P.S. if you switch to any of the following branches the project works as expected

  1. disable-serverless-layers-works preview changes
  2. disable-datadog-works preview changes
  3. disable-swagger-works preview changes
GitHub

Serverless.js plugin that implements AWS Lambda Layers which reduces drastically lambda size, warm-up and deployment time. - GitHub - agutoli/serverless-layers: Serverless.js plugin that implements...

GitHub

Serverless plugin to automagically instrument your Lambda functions with Datadog - GitHub - DataDog/serverless-plugin-datadog: Serverless plugin to automagically instrument your Lambda functions wi...

GitHub

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas: - GitHub - nestjs/swagger: OpenAPI (Swagger) module for Nest framework (node.js)

GitHub

Weird issue preventing breaking lambda when using @nestjs/swagger + serverless-layers + serverless-plugin-datadog - nestjs-swagger-serverless-layers-datadog-issue/README.md at main · Shereef/nestjs...

slow pewter
#

In this line, https://github.com/Shereef/nestjs-swagger-serverless-layers-datadog-issue/blob/main/src/lambda.ts#L53, maybe you should put /dev.

Also, have you tried exporting the AWS Lambda zip file and trying to run it inside your machine? Basically, you can create a random file called test.js, and call your handler with event source from gateway api v2, to see how your application behaves, you can run this file with node --inspect-brk test .js and open your google chrome to directly inspect and create some breakpoints to see what you are getting inside that function that is throwing error.

Or just running locally with https://www.npmjs.com/package/serverless-offline to see if the app breaks.

GitHub

Weird issue preventing breaking lambda when using @nestjs/swagger + serverless-layers + serverless-plugin-datadog - nestjs-swagger-serverless-layers-datadog-issue/lambda.ts at main · Shereef/nestjs...