question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

19reactions
armordogcommented, Feb 13, 2020

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

{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"INVALID_ARGUMENT"},"authenticationInfo":{"principalEmail":"user@domain.ext"},"requestMetadata":{"requestAttributes":{},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/gitl-firebase-dev/locations/us-central1/functions/offerPush"}

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!

6reactions
Enzo-21commented, Sep 14, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found