Chrome-aws-lambda trouble importing

Using this as an example: Netlify-Labs headless chrome

I have successfully set up lambda functions (pretty damn cool!), but I am having a few issues.

My environment

I have node v8.10 installed locally and have strictEngine set in the package.json . I have also pushed this to netlify so I can try outside of my local environment.

What I am trying to accomplish

I need a headless chrome instance so that I can render a canvas and convert it to a png file and send it to Contentful, so using lambda functions should be a good solution.

What I am having problems with.

but I am having trouble importing some packages. Such as, https://github.com/alixaxel/chrome-aws-lambda without getting many errors.

First error: ModuleNotFoundError: Module not found: Error: Can't resolve 'iltorb'

I install iltorb…

Next errors Module not found: Error: Can't resolve 'bufferutil' ERROR in **/node_modules/iltorb/build/bindings/iltorb.node 1:0 Module parse failed: Unexpected character '' (1:0)

I install bufferutil… then these continue to appear… ERROR in /home/mibru/code/clients/mark-maps/node_modules/iltorb/build/bindings/iltorb.node 1:0 Module parse failed: Unexpected character '' (1:0) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file) @ /home/mibru/code/clients/mark-maps/node_modules/iltorb/index.js 10:39-78 @ /home/mibru/code/clients/mark-maps/node_modules/chrome-aws-lambda/source/index.js

Would anyone mind helping me solve this? Or if you know other packages, I am open to using another solution, as long as I can use lambda functions.

I realize it could be including binaries but I am unsure how to work with this stuff.

I appreciate in advance the patience.

1 Like

I have the same issue. Anyone ?

Constant trouble. You will have to upgrade Netlify to handle that large of file. I am currently needing webgl so i have had to use aws lambda instead of Netlify.

Hi @CodeAmend, can you clarify what you mean by “upgrade netlify to handle that large of a file”? Is there a problem with deployment? or are you getting that error when the function is invoked?

Also, are you doing a zip based deploy? What happens if you take that same zip that works on lambda directly and deploy it via Netlify?

Hello Futuregerald,

Netlify is not taking a zip that is a little under 100mb. It will most likely work on Netlify, but i am using aws right now because there is no need to upgrade accounts with this method.

I prob need 1 to 2gb of ram and the ability to wait until a browser has loaded the entire set of map tiles, which could be anywhere from 5 sec to 30sec. So if that would be considered timeout, i am not sure how to handle that.

Hi,

How are you deploying? that’s a big factor. Also note that you can zip the function inside of our build environment. If you have a repo that has the failing deployment then please share a link. Thanks.

Its also the size github can handle. I do not want to push a 70mb file each time i update my commits. Is there a way i can upload a zip to netlify separately? I also dont like the idea of rebuilding this lambda file each time my client pushes a blog post to contentful.

Is there a way to decouple the lambda zip build from each Netlify build?

Do i really need to push a 70mb file to my git repo?

Also, just so you understand, i need to use webgl with headless chrome. This is why the file is so big because chrome is large.

Have you looked in to using git-lfs? that may work for deploying a large file, though I recommend testing it separately and not in production. Netlify Large Media won’t work for this since the file wouldn’t be available during your build step. You can also stash the file in the build cache and restore it from build cache with each deploy. There are libraries that can help with this, like https://www.npmjs.com/package/cache-me-outside

I appreciate you reaching out. If I could just use Netlify platform, I would feel so much better. I will look into this soon.

1 Like