BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News AWS Announces Node.js 14 Support for Its Function as a Service, Lambda

AWS Announces Node.js 14 Support for Its Function as a Service, Lambda

This item in japanese

Bookmarks

Recently AWS announced Node.js version 14 support for its Function as a Service (FaaS), Lambda. Developers can now author AWS Lambda functions using Node.js' new features, such as top-level-await, enhanced diagnostics, modifications of the streams APIs, and a revised JavaScript engine for better performance.

AWS Lambda supports the current Long Term Support (LTS) version of Node.js, which means developers who want to use the new versions need to specify a runtime parameter value of nodejs14.x when creating or updating functions or by using the appropriate managed runtime base image. Node.js 14 is powered by V8 version 8.1, a significant upgrade from the V8 7.4 engine powering the previous Node.js 12.x and brings new features such as operators Nullish Coalescing and Optional Chaining.

Jeremy Daly, AWS Hero, said in a tweet:

Yessa, Node.js 14.x now on Lambda! This means you can now use Nullish Coalescing, which is something you never knew you needed but can't possibly live without now that you have it!

const newVersion = null ?? 'this works great' ;
console.log(newVersion);
// expected output: "this works great"

const nullishTest = 0 ?? 36;
console.log(nullishTest);
// expected output: 0 because 0 is not the same as null or undefined

Furthermore, diagnostic reporting is now a stable feature in Node.js 14, allowing developers to generate a JSON-formatted report on-demand or when certain events occur. It is useful for diagnosing problems such as slow performance, memory leaks, unexpected errors, and more, according to an AWS Compute blog post by Benjamin Smith, senior developer advocate for Serverless at AWS. Moreover, he also wrote:

The following example generates a report from within a Lambda function, and outputs the results to Amazon CloudWatch for further inspection.

const report = process.report.getReport();
console.log(typeof report === 'object'); // true

// Similar to process.report.writeReport() output
console.log(JSON.stringify(report, null, 2));

Smith also wrote that with Node.js 14, the streams APIs had been updated to help remove ambiguity and streamline behaviors across the various parts of the Node.js core. And to help keep Lambda functions secure, AWS updates Node.js 14 with all minor updates released by the Node.js community when using the zip archive format. For Lambda functions packaged as a container image, developers can pull, rebuild and deploy the latest base image from DockerHub or Amazon ECR Public.

A developer can deploy Lambda functions using Node.js 14 by uploading the code through the Lambda console and select the Node.js 14.x runtime or use AWS CLI, AWS Serverless Application Model (AWS SAM), and AWS CloudFormation. Additionally, they can also use the Node.js 14 AWS provided base image to deploy a Node.js 14 function as a container image. And finally, when migrating existing Lambda functions running earlier Node.js versions, developers need to update their code to be compatible with Node.js 14 first and then update the function runtime to Node.js 14.x.

Other public cloud providers like Google and Microsoft also keep updating language support for their FaaS offerings Cloud Functions and Azure Functions. Google recently added support for Ruby, while Azure Functions added Python 3.9 support in public preview last month. As far as support for Node.js 14, Azure Functions had it in public preview since November last year – and also Google Cloud Functions has Node.js 14 in public preview.

AWS Lambda natively supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby code, and provides a Runtime API that allows developers to use any additional programming languages to author their functions. In comparison, Azure Functions natively supports C#, F#, Java, PowerShell, Python, and TypeScript, yet not Ruby or Go. And lastly, Google Functions supports JavaScript, Node.js, Python 3, Go, and Java runtimes on Google Cloud Platform – and even Microsoft.NET languages.

A Hacker Noon blog post showed AWS Lambda is the most popular serverless provider. Furthermore, last year's New Relic 2020 AWS Lambda benchmark report for developers, DevOps, and decision-makers eBook showed that Node.js language is the most popular, with Python as runner up.

The Node.js 14 runtime is currently available in all AWS regions offering the Lambda service. Furthermore, note that AWS will be deprecating Node.js 10 according to the community's end-of-life schedule - on April 30, 2021. More information is available in the runtime support policy. The Node.js 14 runtime will be supported for security and bug fixes until April 2023.

Rate this Article

Adoption
Style

BT