lambdium icon indicating copy to clipboard operation
lambdium copied to clipboard

Can't find module

Open jbizznizz opened this issue 3 years ago • 5 comments

SAM doesn't support one-click deployment of this code because the template references jsnode6. So I uploaded the zip to a new function:

  1. uploaded src file
  2. I ran fetch-binaries.sh to download the binaries into the layer folder
  3. imported the layer folder into a layer and attached it to the function
  4. updated the handler to index.js under Lambda configuraiton
  5. extended Lambda timeout to one minute.

I can't get beyond this error. Any thoughts?

Response { "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'selenium-webdriver/chrome'", "trace": [ "Runtime.ImportModuleError: Error: Cannot find module 'selenium-webdriver/chrome'", " at _loadUserApp (/var/runtime/UserFunction.js:100:13)", " at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)", " at Object. (/var/runtime/index.js:45:30)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)", " at startup (internal/bootstrap/node.js:283:19)" ] }

jbizznizz avatar Mar 07 '21 19:03 jbizznizz

OK so there's a missing step in the instructions for getting dependencies. $ ./src/scripts/fetch-dependencies.sh Re-uploading the src file with the dependencies fixes the problem...

BUT I now get another error:

"errorType": "Error", "errorMessage": "spawn /opt/bin/chromedriver EACCES", "trace": [ "Error: spawn /opt/bin/chromedriver EACCES", " at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)", " at onErrorNT (internal/child_process.js:415:16)", " at process._tickCallback (internal/process/next_tick.js:63:19)"

This is happening right after the example script visitgoogle.js finishes running:

2021-03-08T00:28:17.521Z dbbc20ab-7630-41b0-b73d-493a1a110782 INFO [lambdium-selenium] About to visit google.com... 2021-03-08T00:28:17.523Z dbbc20ab-7630-41b0-b73d-493a1a110782 INFO [lambdium-selenium] Finished running script! 2021-03-08T00:28:17.763Z dbbc20ab-7630-41b0-b73d-493a1a110782 ERROR Uncaught Exception {"errorType":"Error","errorMessage":"spawn /opt/bin/chromedriver

@smithclay @rbrtmrtn @josephfinlayson have you seen this error before? (by the way, thanks a bunch for putting all of this together)

jbizznizz avatar Mar 08 '21 00:03 jbizznizz

I haven't seen that one before. I'd verify execution permissions of the files downloaded in the ./bin directory and chmod +x as needed.

Full disclosure: I haven't made any updates to this project since early 2020 as AWS now offers this functionality as a paid service, see AWS Device Farm Managed Browser Testing.

smithclay avatar Mar 08 '21 01:03 smithclay

That's incredible that they offer it. We're using lambdium to do something other than scrapping and testing, so I'm not sure if Device Farm is the right way to go for us. I need a lambda function to run within our VNC privately.

I'll try the permissions and update here.

jbizznizz avatar Mar 08 '21 01:03 jbizznizz

@smithclay how would you go about chmod’ing? I’ve tried to do it on the files before zipping but .zip doesn’t preserve file permissions like tar does. I don’t see a way to change file permissions with AWS CLI - I’ve also tried uploading the code to an S3 bucket, but that doesn’t seem to have a chmod option either.

jbizznizz avatar Mar 08 '21 20:03 jbizznizz

I think I figured out the permission part, but now i have a new error. Other forums indicate a dependency problem. Any thoughts?

EDIT After some more research, it looks like Amazon's upgrade to Linux 2 might have removed some of the dependencies that this code had relied on previously. I'll try the link and report back.

{ "errorType": "Error", "errorMessage": "Server terminated early with status 127", "trace": [ "Error: Server terminated early with status 127", " at earlyTermination.catch.e (/var/task/node_modules/selenium-webdriver/remote/index.js:252:52)", " at process._tickCallback (internal/process/next_tick.js:68:7)", "From: Task: WebDriver.createSession()", " at Function.createSession (/var/task/node_modules/selenium-webdriver/lib/webdriver.js:769:24)", " at Function.createSession (/var/task/node_modules/selenium-webdriver/chrome.js:761:15)", " at Object.exports.createSession (/var/task/lib/chromium.js:65:24)", " at Object. (/var/task/index.js:16:23)", " at Module._compile (internal/modules/cjs/loader.js:778:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)", " at Module.load (internal/modules/cjs/loader.js:653:32)", " at tryModuleLoad (internal/modules/cjs/loader.js:593:12)", " at Function.Module._load (internal/modules/cjs/loader.js:585:3)", " at Module.require (internal/modules/cjs/loader.js:692:17)", "From: Task: WebDriver.navigate().to(http://www.google.com/ncr)", " at Driver.schedule (/var/task/node_modules/selenium-webdriver/lib/webdriver.js:807:17)", " at Navigation.to (/var/task/node_modules/selenium-webdriver/lib/webdriver.js:1133:25)", " at Driver.get (/var/task/node_modules/selenium-webdriver/lib/webdriver.js:988:28)", " at evalmachine.:9:10", " at Script.runInContext (vm.js:133:20)", " at Object.exports.executeScript (/var/task/lib/sandbox.js:78:12)", " at Runtime.exports.handler (/var/task/index.js:35:11)", " at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)" ] }

jbizznizz avatar Mar 08 '21 21:03 jbizznizz