Random `Function failed on loading user code. Error message:` with no error message
See original GitHub issue[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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Firebase error: Function failed on loading user code (node.js)
Enter this command for getting log: firebase functions:log.
Read more >Troubleshooting Cloud Functions - Google Cloud
"Function failed on loading user code. This is likely due to a bug in the user code." The solution. For a more detailed...
Read more >Deployment error. Function failed on loading user code. Error ...
Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause ... ENOENT: no such...
Read more >What went wrong? Troubleshooting JavaScript - MDN Web Docs
The error message says "guessSubmit.addeventListener is not a function", which means that the function we're calling is not recognized by ...
Read more >Cloud Build error when trying to update ... - Issue Tracker
Ok, probably it's a problem with Firebase CLI deploy management. Just created a random function through browser at Google Cloud, deployed from Firebase...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
require
s 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.