firebase-tools: Random `Function failed on loading user code. Error message:` with no error message
[REQUIRED] Environment info
firebase-tools: 7.12.1
Windows 10
[REQUIRED] Test case
Deploying any function ever.
[REQUIRED] Steps to reproduce
Deploy more than one function. Half of the time, one or more will fail with
Function failed on loading user code. Error message: and nothing else.
[REQUIRED] Expected behavior
Please give me information so I know why the deploy failed.
[REQUIRED] Actual behavior
I get no useful information and have to restart builds all the time.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 17 (5 by maintainers)
Hey @samtstern!
I talked to Firebase support and they helped me understand enough to fix it. =]
Turns out that in my firebase logs I was getting something like
which apparently means that the function timed out on its initial startup.
So I needed to move some of my top-level
requires inside the functions so they don’t happen on cold-start.I just thought you (or anyone who finds this later) would like to know.
Thanks again!
Check if you have some dependencies installed on your root folder. You should have all your modules installed inside the functions folder. Only firebase dependencies should be in your root folder. Try to do npm uninstall yourDependencie inside your root folder and then npm i yourDependencie inside root/functions folder.
@Enzo-21 Thank you very much. This solved my problem. I ran npm install from inside functions folder for the package I needed and it worked like charm.
@armordog there are no situations where we want to give you no error message. That’s clearly a bug. The issue is that we can’t fix this unless we can reproduce it on our machine and then dig into it. So any more information is really useful.
I know you said the
--debuglogs were not useful but could you post them anyway? Also you mention restarting builds, is this often fixed by running the samedeploycommand again?@armordog we’re gonna need a little more information to track this down. When you say “Deploying any function ever.” do you mean that this happens even if you just deploy a
helloWorldfunction?Could you try running
firebase init functionsin a temporary directory somewhere and then doingfirebase deployand seeing if you still see this error?Also, running deploy with
--debuggives me a lot more output but it’s all successes until the above-mentioned useless error.