CI/CD Issue for Node 18.x Runtime

I am having an issue with the nodejs 18.x runtime in CI/CD.

Despite specifying the Node 18.x in my serverless.yml:

provider:
  name: aws
  runtime: nodejs18.x

I am seeing Node 12.x selected in the build:

Build started at Thu Jan 19 2023 17:29:28 GMT+0000 (GMT)

> node --version

v12.22.11

Specifying Node 16 in serverless.yml yields the correct build environment, so I am a bit confused.

Any ideas what might be happening?

2 Likes

I am facing the same issue, I have to deploy using 18.x because one of the packages I use needs it. Is there any solution?

Same issue for me too.

1 Like

Since serverless framework lacks support for Nodejs18.x and aws-sdk-v3 so I created a topic on it as below. Please support it

1 Like

It looks to me like this is the core issue, as you have identified. Serverless Framework does not yet support AWS SDK v3. Lambda requires us to use SDK v3 in order to use nodejs 18 or higher (nodejs 20 is available now). So we Serverless/Lambda users are stuck on nodejs 16 for now.

It is understandable that it will take some time for Serverless to do it right, however. From what I am reading it looks like the modularity and usage of layers in Lambda are quite different. So all the code that executes when we do serverless deploy will have to change fairly dramatically.

Can we get a statement of intent or timeframe estimate from anyone about support sdk v3?

I posted in the Serverless Slack channel, so hopefully Iā€™ll get a response there. Iā€™ll post any response I get here for you folks to see as well.

1 Like

Okay gang, I jumped into the Serverless Slack and discussed this problem with a super helpful guy there. He helped me understand that there really is no inherent connection between serverless and aws-sdk. So you can continue using aws-sdk v2 while increasing the provider/runtime to nodejs18.x in serverless.yml. The key is that you have to make sure that aws-sdk is installed as a dependency rather than as a devDependency. You can do this nice and safely by doing this:

npm uninstall aws-sdk
npm install aws-sdk

That was all I needed, and then I could go into serverless.yml and go to provider: runtime and upgrade from nodejs16.x to nodejs18.x. Now Iā€™m running serverless with nodejs18 in AWS Lambda.

The whole issue of upgrading serverless to aws-sdk v3 is a separate issue because when following this path we are packaging up aws-sdk v2 with our code and loading it all into Lambda. Eventually sure it would be nice to not have to package aws-sdk v3 but serverless is not there yet. Also it looks like there will be some breaking code changes when we get there. Nothing horrible but must focus on it. This article has info on that when you are ready for it:

But Iā€™m not going to approach it until serverless approaches it for me.

Enjoy!

1 Like

Hi, I have tried as you mentioned, now downgraded to aws sdk version 2 from version 3 and trying to use nodejs 18 runtime in provider in serverless.yml but getting error as ā€œfound unsupported runtime nodejs18.xā€.
I want to use nodejs 18 as runtime in serverless framework..

Also, could you please tell me what is the serverless version you are using to support nodejs 18 runtime and aws sdk version 2.

Sharing my version

ā€œaws-sdkā€: ā€œ^2.943.0ā€, (tried latest version as well for version 2 - 2.140.0)
ā€œserverlessā€: ā€œ^2.60.0ā€,
ā€œserverless-gulpā€: ā€œ^1.0.9ā€,
ā€œserverless-offlineā€: ā€œ^8.6.0ā€,
ā€œserverless-webpackā€: ā€œ^5.3.3ā€,

Getting this error while running serverless offline --stage=stage
offline: GET /stage/inspection/get_auction_codes (Ī»: inspection_getAuctionCodes)

offline: Warning: found unsupported runtime ā€˜nodejs18.xā€™ for function ā€˜inspection_getAuctionCodesā€™
offline: Failure: Unsupported runtime
Error: Unsupported runtime

Could you please help me on this?

You definitely have to upgrade to serverless 3.32.2 which is not the same as upgrading to aws sdk v3.

A

thanks it worked.
Initially i was getting same issue even after installing this version but then i installed serverless globally then worked.

Hi, As you said I have upgraded serverless till 3.32.2 also downgraded aws sdk till version 2 and using nodejs 18 as a runtime provider. Every thing was looking fine initially but now getting some issue in lambda while calling as below.

**Uncaught exception **
error
The security token included in the request is invalid

We have identified this issue seems coming from serverless. we did some syntax level changes as well like * provider.role ā†’ provider.iam.role but still not working and issue is coming.

Sharing some similar thread I found on internet

Here I am using role base acces so not using aws access and secret key.
Could you please help me out how to fix it?

Sorry to hear of your trouble! I donā€™t have any specific experience with this error, sorry. But I would say the best possible thing you can do is use the ā€œdivide the lineā€ approach to debugging. This means:

  • Back out changes and get back to a known-good state
  • Skillfully determine which changes are 50% between this known-good state and the broken state, and re-introduce only those changes, and then test.
  • Loop this previous step over and over, and it should take you no more than 7 iterations to solve even the most difficult of bugs.
  • If it takes you more than 7 tries that means you are not selecting the 50% point correctly.

This has ALWAYS worked for me over 25+ years of hard core software development.

Best to you!

A

@gourabb8273 I am facing below issue
nodejs18.xā€
I have changed from 14 to nodejs 18 as runtime in serverless framework.
Getting unsupported runtime.also ihave updated all my serverless dependencies including aws-sdk to v3 .
can you suggest how to resolve this.

Donā€™t upgrade the aws sdk to v3. Thatā€™s what is unsupported!

Alan Neveu
alan@mojosportclinic.com
910-508-1112

I got it working here.

Serverless Framework V3.35.2
NodeJS v18.17.1
@aws-sdk v3

And I needed to pack aws-sdk v2 together because ā€œaws-xray-sdkā€ uses it.