chrome-aws-lambda icon indicating copy to clipboard operation
chrome-aws-lambda copied to clipboard

Add support for nodejs16.x

Open styfle opened this issue 3 years ago • 13 comments
trafficstars

https://aws.amazon.com/about-aws/whats-new/2022/05/aws-lambda-adds-support-node-js-16/

  • Related to #275

styfle avatar May 13 '22 13:05 styfle

@alixaxel It would be awesome to get this one merged so that we are able to run on the latest runtime 🙏

shooit avatar Jun 07 '22 16:06 shooit

We would be really grateful if this can be merged, it's blocking us from upgrading our infra on Lambda. 🙏

VesterDe avatar Jun 20 '22 09:06 VesterDe

Please merge it, as it's crucial for to use it with Node.js v16.

bitconym avatar Jun 27 '22 09:06 bitconym

We need this as well. It would be really great if @alixaxel could merge it. Thank you!

turakvlad avatar Jun 28 '22 11:06 turakvlad

It would be really great

Spawnrad avatar Jul 06 '22 13:07 Spawnrad

@alixaxel is this repo maintained? Any reason why so much delay with merging this update? Almost 2 months...

bitconym avatar Jul 06 '22 13:07 bitconym

Works like a charm. I use patch-package with the following patch file as a workaround for now:

diff --git a/node_modules/chrome-aws-lambda/build/index.js b/node_modules/chrome-aws-lambda/build/index.js
index f78e183..599af55 100644
--- a/node_modules/chrome-aws-lambda/build/index.js
+++ b/node_modules/chrome-aws-lambda/build/index.js
@@ -7,7 +7,7 @@ const fs_1 = require("fs");
 const lambdafs_1 = __importDefault(require("lambdafs"));
 const path_1 = require("path");
 const url_1 = require("url");
-if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
     if (process.env.FONTCONFIG_PATH === undefined) {
         process.env.FONTCONFIG_PATH = '/tmp/aws';
     }
@@ -145,7 +145,7 @@ class Chromium {
             lambdafs_1.default.inflate(`${input}/chromium.br`),
             lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`),
         ];
-        if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+        if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
             promises.push(lambdafs_1.default.inflate(`${input}/aws.tar.br`));
         }
         return Promise.all(promises).then((result) => result.shift());

Save this file in your project as patches/chrome-aws-lambda+10.1.0.patch, install patch-package and add the following script to your package.json:

 "scripts": {
+  "postinstall": "patch-package"
 }

urish avatar Jul 19 '22 12:07 urish

@Edweis are you going to maintain this project since I see you approved the PR? Can you merge it? I switched using https://github.com/Sparticuz/chrome-aws-lambda since @Sparticuz currently maintains it.

bitconym avatar Aug 03 '22 07:08 bitconym

Works like a charm. I use patch-package with the following patch file as a workaround for now:

diff --git a/node_modules/chrome-aws-lambda/build/index.js b/node_modules/chrome-aws-lambda/build/index.js
index f78e183..599af55 100644
--- a/node_modules/chrome-aws-lambda/build/index.js
+++ b/node_modules/chrome-aws-lambda/build/index.js
@@ -7,7 +7,7 @@ const fs_1 = require("fs");
 const lambdafs_1 = __importDefault(require("lambdafs"));
 const path_1 = require("path");
 const url_1 = require("url");
-if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
     if (process.env.FONTCONFIG_PATH === undefined) {
         process.env.FONTCONFIG_PATH = '/tmp/aws';
     }
@@ -145,7 +145,7 @@ class Chromium {
             lambdafs_1.default.inflate(`${input}/chromium.br`),
             lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`),
         ];
-        if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
+        if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
             promises.push(lambdafs_1.default.inflate(`${input}/aws.tar.br`));
         }
         return Promise.all(promises).then((result) => result.shift());

Save this file in your project as patches/chrome-aws-lambda+10.1.0.patch, install patch-package and add the following script to your package.json:

 "scripts": {
+  "postinstall": "patch-package"
 }

Hi @urish, looking to try this approach in the short term till this gets commited. I get using patch-package, I'm a little confused on what constitutes "the following patch file" in your example - is it, literally, copying the code segment in your example to patches/chrome-aws-lambda+10.1.0.patch? Or copying the entire updated file from the commit on github?

Thanks!

shaunhurley avatar Aug 28 '22 23:08 shaunhurley

Would be great to merge this, is there anything blocking this PR? would be happy to help if there is

tudorsandu avatar Sep 01 '22 08:09 tudorsandu

can we get this merged please?

truuth-of-abhi avatar Sep 18 '22 12:09 truuth-of-abhi

@truuth-of-abhi I don't think the repository is maintained anymore, better to switch to this fork: https://github.com/Sparticuz/chrome-aws-lambda

bitconym avatar Sep 19 '22 09:09 bitconym

The latest repository is https://www.npmjs.com/package/@sparticuz/chromium. Working well with node 18 and AWS Lambda.

experionsachin avatar Mar 23 '23 20:03 experionsachin