Skip to content

Fail gracefully if gRPC isn't available #1297

Closed

Description

@jgeewax

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?

Activity

  1. stephenplusplus commented on May 9, 2016

    @stephenplusplus
    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?

  2. pputhran commented on May 10, 2016

    @pputhran

    @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.

  3. stephenplusplus commented on May 10, 2016

    @stephenplusplus
    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.

  4. jgeewax commented on May 10, 2016

    @jgeewax
    ContributorAuthor

    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 ?

  5. stephenplusplus commented on May 10, 2016

    @stephenplusplus
    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.

  6. ajagnanan commented on May 14, 2016

    @ajagnanan

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

  7. stephenplusplus commented on May 16, 2016

    @stephenplusplus
    Contributor

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

  8. pputhran commented on May 16, 2016

    @pputhran

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

  9. stephenplusplus commented on May 17, 2016

    @stephenplusplus
    Contributor

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

  10. ajagnanan commented on May 17, 2016

    @ajagnanan

    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.

  11. stephenplusplus commented on May 23, 2016

    @stephenplusplus
    Contributor

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

  12. stephenplusplus commented on Jun 1, 2016

    @stephenplusplus
    Contributor

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

  13. anil100nair commented on Sep 9, 2018

    @anil100nair

    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.

  14. JustinBeckwith commented on Sep 9, 2018

    @JustinBeckwith
    Contributor

    👋 Which specific module are you trying to use?

  15. anil100nair commented on Sep 10, 2018

    @anil100nair

    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)
    
  16. JustinBeckwith commented on Sep 10, 2018

    @JustinBeckwith
    Contributor

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

  17. anil100nair commented on Sep 11, 2018

    @anil100nair

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

  18. added a commit that references this issue on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions