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

Fail gracefully if gRPC isn't available #1297

Closed
jgeewax opened this issue May 9, 2016 · 17 comments
Closed

Fail gracefully if gRPC isn't available #1297

jgeewax opened this issue May 9, 2016 · 17 comments
Assignees
Labels

Comments

@jgeewax
Copy link
Contributor

jgeewax commented May 9, 2016

Re #1287 , seems like there are cases where gRPC won't be able to be initialized. I understand if a service that requires gRPC (ie, Bigtable) failed in these cases, but if an unrelated module fails because of the unused gRPC import, that makes me sad....

Can we try to fail gracefully if gRPC isn't installed in the environment for whatever reason?

@stephenplusplus
Copy link
Contributor

Yeah, you would think the gRPC installation would have errored if the system couldn't handle it. @pputhran -- when you were running the code from #1287, did you let the server run npm install for itself, or did you push the exact files from your local node_modules directory?

@pputhran
Copy link

@stephenplusplus, in aws lambda, we need to package and push the node_modules from local. It does not have a way to run npm install. I was able to work around the problem by using the gcloud module which was install on linux box.

@stephenplusplus
Copy link
Contributor

Ah, okay. Does that "Native Modules" section in this guide explain something similar to what you had to do?

@jgeewax Code that was compiled for one environment was copied to another that didn't match. Under a normal installation -> run cycle, if a dependency cannot be installed, npm install would fail, so it wouldn't be expected for our library to operate correctly. I don't believe we should try/catch our own dependencies, because that's what npm install is supposed to handle for us.

@jgeewax
Copy link
Contributor Author

jgeewax commented May 10, 2016

OK, I hear where you're coming from @stephenplusplus , however the end goal is "gcloud-node should work inside AWS lambda"... Can we figure out how to do that ?

@stephenplusplus
Copy link
Contributor

Yeah, I think @pputhran can fill us in on that experience. That guide I linked above is from AWS specifically for using Node modules that have native dependencies, like ours. We of course aren't the only such dependency a user might have, so the solution should likely come from the AWS side on how it can be made as easy as possible.

@ajagnanan
Copy link

Im running into this issue too, is there a way to build an aws lambda friendly gcloud-node module?

@stephenplusplus
Copy link
Contributor

@pputhran @ajagnanan can you guys try out https://github.com/tomdale/lambda-packager? Looks like it might be just what we need.

@pputhran
Copy link

@stephenplusplus thank you. this looks like what we need. will try this and let you know

@stephenplusplus
Copy link
Contributor

Great, if it works for you and @ajagnanan, we'll add it to our Troubleshooting guide.

@stephenplusplus stephenplusplus self-assigned this May 17, 2016
@ajagnanan
Copy link

I'm developing on a mac. What I did was compile 2 versions of the module, 1 locally on my mac and 1 on an ec2 instance which I copied down locally. I put these two in a separate folder (/bin). I then set up hook scripts to copy the version needed for the environment i'm running on to the node_modules folder. I haven't tested the lambda-packager yet, but this would save me from manually compiling it on an ec2 instance if it works.

For reference, I'm using https://github.com/serverless/serverless with plugin https://github.com/kennu/serverless-plugin-hookscripts.

@stephenplusplus
Copy link
Contributor

Thanks for the breakdown @ajagnanan. Have you tried lambda-packager yet?

@stephenplusplus
Copy link
Contributor

@pputhran if you've tried it yet, how did it go?

@anil100nair
Copy link

I have encountered the same issue. Can someone help me resolve this issue?

Since there hasn't been any recent posts on this issue, I assume there is a way to resolve this. I tried lambda-packager and it seems like the repository is deprecated.

@JustinBeckwith
Copy link
Contributor

👋 Which specific module are you trying to use?

@anil100nair
Copy link

Hi @JustinBeckwith, I am using the module @google-cloud/automl. It is working perfectly fine in the local environment but when pushed to lambda, it fails giving the following error:

Unable to import module 'handlers/classification': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/task/node_modules/google-gax/build/src/grpc.js:87:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

@JustinBeckwith
Copy link
Contributor

@anil100nair thanks for the details! Would you mind opening a new issue on this repository? Thank you :)
https://github.com/googleapis/nodejs-automl

@anil100nair
Copy link

Thanks you for your time. I'll open an issue.

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

No branches or pull requests

6 participants