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

CI layer artifact double zipped – Lambda Cannot find module

Open Daemach opened this issue 4 years ago • 4 comments

I installed the 10.0 version of the chrome-aws-lambda as a layer this morning. I then tried to use your example usage code, slightly modified to generate a pdf, as a test. I got an error saying Error: Cannot find module 'chrome-aws-lambda' Here's a screenshot. Should this not just work? https://www.screencast.com/t/AlCJDpNG

It's probably my lack of experience with Lambda. I could use some advice in any case.

Daemach avatar Jul 15 '21 15:07 Daemach

The layer wasn't working because the CI/CD process builds a zip within a zip. Extracting the inner zip file and using that as the Lambda layer seems to have worked. It would be good to make a note of this in your readme.

Thanks for your work!

Daemach avatar Jul 15 '21 15:07 Daemach

Thanks @Daemach

This is especially relevant, as some tools like the Archive Utility builtin to macOS unpack the two layers of zip compression in one go. As the structure that gets unpacked looks correct, this is very hard to debug.

It is caused by this upstream issue of GitHub Actions https://github.com/actions/upload-artifact/issues/39

Nonetheless, until that's fixed I would vote to reopen this issue to make this easier to find for others. (Maybe renaming it to something like "CI layer artifact double zipped – Lambda Cannot find module")

timbodeit avatar Jul 20 '21 19:07 timbodeit

Sidenote: To only unzip the first layer of compression under macOS, run unzip chrome_aws_lambda.zip in the Terminal.

timbodeit avatar Jul 20 '21 19:07 timbodeit

I downloaded it from the CI/CD as well, uploaded it to AWS, and spent a day trying to fix the module not found. After reading this, solved my problem in 3 minutes. Thanks @Daemach

lehno avatar Oct 22 '21 08:10 lehno