Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 16.x is supported? #275 #42

Closed
outaTiME opened this issue May 21, 2022 · 15 comments
Closed

Node 16.x is supported? #275 #42

outaTiME opened this issue May 21, 2022 · 15 comments

Comments

@outaTiME
Copy link

I am having the following error when I try to run my lambda with node 16.x, does anyone else get this?

 "Failed to launch the browser process!\n/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory\n\n\nTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n"
@kosanna
Copy link

kosanna commented Jun 9, 2022

Have you tried downgrading? Did it work? Going to try with 14 and see if it fixes the issue 🤔

UPD: Looks like it worked. At least no missing libs issue anymore. But now I have browser hanging :D Fun

@vladholubiev
Copy link
Member

Right, this layer depends on https://github.com/alixaxel/chrome-aws-lambda and the upstream repo hasn't been updated to support Node 16 yet.

I see @outaTiME already raise the issue there: alixaxel/chrome-aws-lambda#275

@vladholubiev
Copy link
Member

I've just published a new layer version 27 that has the latest Chromium and Node 16 support!

Thanks again for pointing this out!

@outaTiME
Copy link
Author

outaTiME commented Jun 11, 2022

Hi @vladgolubev,
for some reason the new layer does not work for me, it gives me the following error:

{
    "error type": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@sparticuz/chrome-aws-lambda'\nRequire stack:\n- /var/task/src/subscribers/social-notify.js\n- /var/ runtime/index .mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '@sparticuz/chrome-aws-lambda'",
        "Require stack:",
        "- /var/task/src/subscribers/social-notify.js",
        "- /var/runtime/index.mjs",
        " at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
        " at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
        " in async file:///var/runtime/index.mjs:781:15",
        " in async file: ///var/runtime/index.mjs:4:1"
    ]
}

but if I manually download and configure the artifact (https://github.com/Sparticuz/chrome-aws-lambda/suites/6829349165/artifacts/263061533) it works like a charm,

could it be that you have left some misconfigured route when you did the deployment?

@vladholubiev
Copy link
Member

@outaTiME hm, strange, what I did is just package the same artifact zip as is into a layer

Maybe it's b/c zip has extra nodejs folder inside?

I've just published v28 with that change, could you please try it ?

@vladholubiev vladholubiev reopened this Jun 13, 2022
@outaTiME
Copy link
Author

outaTiME commented Jun 13, 2022

Unfortunately using 28 throws the same error, locally my structure for the layer is as follows:

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@sparticuz/chrome-aws-lambda'\nRequire stack:\n- /var/task/packages/api/src/subscribers/social-notify.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '@sparticuz/chrome-aws-lambda'",
        "Require stack:",
        "- /var/task/packages/api/src/subscribers/social-notify.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
        "    at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
        "    at async file:///var/runtime/index.mjs:781:15",
        "    at async file:///var/runtime/index.mjs:4:1"
    ]
}

the error message gives the feeling that the @sparticuz/chrome-aws-lambda package is not available within the layer (or at least within that file structure),

and as I told you before, I simply unzipped the artifact in a folder called "chrome":

image

I also tell you that I am using SST, I show you a little about the definition of my layer:

const layerArn =
  "arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:28";

  socialNotify: {
  function: {
    handler: 'src/subscribers/social-notify.handler',
    bundle: {
      externalModules: ['@sparticuz/chrome-aws-lambda'],
    },
    layers: [
      new lambda.LayerVersion(stack, 'ChromeLayer', {
        code: lambda.Code.fromAsset('packages/api/layers/chrome'),
      }),
      // commented out to leave the local layer which is the one that works
      // LayerVersion.fromLayerVersionArn(stack, "ChromeLayer", layerArn),
    ],
    // ~30s
    timeout: '1 minute',
  },
  cdk: {
    subscription: {
      filterPolicy: {
        event: SubscriptionFilter.stringFilter({
          allowlist: ['social-notify'],
        }),
      },
    },
  },
},

@vladholubiev
Copy link
Member

So apparently, embedding node_modules inside nodejs folder is required, so I reverted that change in the v29.

I'm not familiar with SST so maybe the issue is with it somehow?

@outaTiME
Copy link
Author

outaTiME commented Jun 13, 2022

Regardless of SST and the layer has to have the following structure nodejs/node_modules (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html), I just did a download of your layer 28 as follows:

$ aws lambda get-layer-version-by-arn --arn "arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:28"

and looking at the contents I see that the nodejs folder does not exist, unlike layer 25, which does have one, I am enclosing a reduced comparison of the contents between both versions:

image

btw, you can also see some dirt in the zip, like the descriptors (__MACOSX) which can possibly be removed to make everything much cleaner

@vladholubiev
Copy link
Member

@outaTiME what about layer version 29? it should have the nodejs enclosing folder now.

Thanks for pointing out the dirt. I can see that + some other stuff to be removed (like .d.ts files or browser build of libraries)

@outaTiME
Copy link
Author

outaTiME commented Jun 13, 2022

yay, @vladgolubev, the layer 29 works amazing 🚀

Thank you very much, for all your work and support !!!

@vladholubiev
Copy link
Member

You're welcome! And thank you too!

v30 w/o junk (~2 MB of junk removed) will be published as soon as Docker Hub will get up 🙂

https://app.circleci.com/pipelines/github/shelfio/chrome-aws-lambda-layer/71/workflows/256fa5ce-a50f-4f32-a892-6e2bdadb8112

@outaTiME
Copy link
Author

Great, I'm trying a new layer 30 as soon as it's available, thanks again !!!

@outaTiME
Copy link
Author

I just downloaded layer 30, and I keep seeing dirt in the __MACOSX folders, could it be?

@vladholubiev
Copy link
Member

Automated zipping via create-zip.sh as turns out macOS will create that junk if you zip from UI.

Now it shouldn't be!

I've published v31 and I don't see any that junk anymore!

CleanShot 2022-06-13 at 16 59 50@2x

@outaTiME
Copy link
Author

sweet, everything works amazing, thanks again @vladgolubev !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants