Error when deploying to AWS Lambda (Node 6.10.3)
I'm getting a "Unable to import module" error when deploying v5.3.0 or above to AWS Lambda. The error log is cryptic but it does contain reference to "firebase-admin/node_modules/grpc/src/node/src/grpc_extension.js:30:15"
All works as expected when downgrading to v5.2.1.
@shauntrennery Same here! I did downgrade firebase-admin lib to 5.2.1 but no luck. How did you solve it?
https://github.com/firebase/firebase-admin-node/issues/105
@srameshr I'm sorry, my solution was simply downgrading to 5.2.1. No other changes were needed.
Have you done any changes to files in .ebextensions?
v5.2.1 doesn't depend on Firestore/grpc. @srameshr what is the exact error you get with v5.2.1?
I've pinged the Firestore SDK team about the grpc error. Awaiting their response.
@srameshr I did not. 100% sure.
GRPC requires native code. There's some discussion about how to make this work here https://github.com/grpc/grpc/issues/6443
@hiranya911 Let me deploy v5.2.1 again and check the logs, in the meanwhile I will update the question with my package.json file.
@hiranya911 It's the same. Even on 5.2.1 it gives me the same error.
That doesn't make any sense. grpc wasn't a dependency until v5.4.0. Have you tried deleting your node_modules directory, and installing v5.2.1 on a fresh set up?
@hiranya911 AWS EB is a nightmare. I removed firebase-admin from my package.json and deployed a new build and it still says gprc is not found.
I will restart my env and check the logs.
@shauntrennery can you share any detailed logs you have when you were experiencing this issue? We would like to get a better handle of this problem, and see how AWS users can be impacted.
@hiranya911 Here is the log from CloudWatch:
Unable to import module 'survey': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/task/node_modules/firebase-admin/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
As mentioned, all I need to do to resolve the issue was to downgrade to version 5.2.1. No other changes were needed.
Thanks @shauntrennery. FWIW you should be able to get by with v5.3.0 as well.
@hiranya911 I ssh into my eb machine and see that, package.json does not include firebase-admin and node-modules does not have firebase admin but still my latest deployment logs show the same error.
@srameshr Please share your logs. Perhaps we can try to trace down why it tries to load grpc. But given that Admin SDK is out of the picture, it's probably some other dependency you're using.
@hiranya911 Yes, I will. Just running my tests against 5.3.0 on production. After that I will get the logs. My previous comment was a result of some caching fault I guess. But I am sure, grpc error came from including firebase-admin module > 5.3.0
same error here, can confirm that it works with firebase 5.3.0 as expected (for me).
@PutziSan can you also share your logs? More info we have, easier it will be for us to resolve this.
And just FYI, there is some work in progress to fix this. We are trying to get to a state where the Admin SDK doesn't always try to import Firestore/grpc. This requires:
- Separating Firestore type definitions into a separate module.
- Lazy loading the Firestore namespace (
admin.firestore).
@hiranya911 do you foresee a fix coming anytime soon to get Firestore running on AWS Lambda with this grpc dependency?
I know this thread is about firebase-admin, but I also would like to get firestore running on Lambda as well.
@schmidt-sebastian @wilhuff can you comment on the status of Firestore/grpc support on AWS Lambda environment?