-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification #5888
Comments
I had the same error in almost the same environment as you. |
Hi @sunwupark, thanks for reporting this error. From the details you provided, it's difficult to diagnose the underlying issue causing your functions code to not load. Could you provide your source code, or a simple example that I could use to reproduce your issue? Thanks. |
I had the same problem, downgrading also worked for me -- thanks @saitogo555 ! |
Got the same error Error: User code failed to load. Cannot determine backend specification. Turns out that when I initialized a new project using Firebase init the default nodejs version it uses is 18. Just needed to change my version in the package.json file to the current one installed on my system. For me, it was 16. "engines": { "node": "16" }, |
We had same problem when we use wsl and mnt folder(local windows). |
Hey @sunwupark. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @sunwupark if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
I'm trying a very basic function and it's failing while deploying. My project is on the Windows partition, while I'm deploying from WSL2 terminal. I was using the latest
and I installed a previous version
as suggested by @sunwupark 🎊 |
How did you end up fixing it using this issue? Since the folder I'm trying to access is going through /mnt/c/Users/... |
In my case, I run the deploy twice and it succeeds. |
Downgrading also worked for me |
In my case, I run the deploy twice and it succeeds too, but eventually it happens again and I need to deploy a or serve a second time to works. So, maybe there is a problem with de latest version |
It's sad to disclose here that even using the latest Firebase tools version 12.4.2 had no effect! The error Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification kept on rising, tried it with cmd, PowerShell & Git bash but no luck. Instead, I had to downgrade to version 11.29.1 as mentioned by @hamen just to execute the firebase functions scripts:
{
"serve": "npm run build && firebase emulators:start --only functions",
},
"engines": {
"node": "16"
}, I am using Node Version Manager, my node version is v16.20.0 & npm version is 9.6.7. A humble request to the team to please resolve this error on high priority. |
I started having the issue after cloning my disc onto a new one. Now whether it's to run |
same problem here using |
Same bug here |
Experiencing this intermittently while developing with python. Seems the only solution we have found, haven't tried downgrading, is removing the functions folder, and Firebase config, and re-initing which will resolve it, but is not a good solution. |
As I already posted at the beginning of the thread, downgrading the firebase-tools version to 11.29.1 works fine. if you still get the error after trying with 11.29.1, we can all work out a solution. |
Downgrading isn't quite a proper solution, it can be a workaround. By downgrading, we are missing all the latest features, commands & bug fixes that are being introduced with the release of the new Firebase tools CLI. |
related #5834 |
Thanks for sharing this. I am currently using Firebase CLI version 12.4.4 & applied the below steps. It seems to be working at least after failing once (sometimes). P.S. I know it's not right to manipulate the JS build code, but I couldn't find any other option. These steps have been created by observing #5834 file changes
A friendly suggestion for @takahashi-shotaro is that you could upgrade your current Pull Request branch & re-submit the code. Maybe the Firebase team would reconsider looking into it. |
@jeanmatthieud now there is the solution... you can find the fix on node_modules\firebase-tools\lib\deploy\functions\runtimes\discovery> |
Yes, I know but finding this GitHub issue took me so much time (I believed that my code was the issue, as it didn't appeared at first, when the project was smaller). |
Downgrading firebase tools version and chancing the runt time for functions to nodejs 16 seemed to fix my issue. |
marco-mastella's method to add FUNCTIONS_DISCOVERY_TIMEOUT=50 (50 are seconds, you can increase) to environmental variables work for firebase-tools 13.15.0 and Python 3.10.11 on Windows 11 |
I had the same issue but after I installed the same version of firebase-cli that i have in my project, it is resolved! |
I was having the same issue. I searched through internet and spent hours finding a fix for this at last @tarpagad's solution worked for me.
@firebase-ops team should resolve this issue on high priority because it's wasting dev time. |
Yes
…On Tue, 13 Aug 2024 at 8:08 AM, John D. Underhill ***@***.***> wrote:
@Umer-309 <https://github.com/Umer-309> did you see #7176
<#7176>?
—
Reply to this email directly, view it on GitHub
<#5888 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4BYZAFP5VYHRSMOKK3XXMTZRF2BXAVCNFSM6AAAAAAYMSYVHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBVGI2TMNZSG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
for me upgrading firebase-tool to latest 13.15.4 solved the issue. |
dear god... I have spent 2 hours with this issue :( npm install -g firebase-tools its worked for me |
I get this about 50% of the time. I find just retrying resolves it. |
10 September 2024
I have observed that,
I do not have any real idea, as it does work some of the time and not the other time, and deployed functions are working fine so I seriously doubt it has anything to do with my own Typescript based functions. |
Had the same issue with firebase-tools v12.6.1 on a Nest.js project. |
Updating firebase-tools from13.15.0 to 13.19.0 fixed the problem |
@urosran |
Still happens in tools 13.22.0 and with python 3.12 functions |
Not sure if this could be a hint.. but I've been trying to test cloud functions in local emulator and had the same error. After running
Maybe it's somehow not recognizing the js file that has cloud function codes? |
There is an open issue #7775 in firebase-tools. |
By reading the firebase source code, it is looking for So, in my firebase.json
I had to copy package.json under |
It's quite disappointing that Firebase doesn't fix this after all these years. |
updated to the latest firebase version (again), still get the error |
Same issue |
Still having this issue on 13.27.0, and the above seems to be the only thing that works. Thanks! |
Is the
|
how can you verify this variable is set correctly? |
Well, for me, the error goes away :) |
You 'found' something that was posted back in June and I commented on last week. I swear people just aren't reading this thread... |
[REQUIRED] Environment info
firebase-tools:
firebase-tools: 12.1.0
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
"firebase-functions-test": "^3.1.0"
**Platform: Windows wsl (Ubuntu)
Node: v18.16.0
Python: v3.10.6
openjdk: v"11.0.19"
[REQUIRED] Test case
i have followed the exact steps in
https://firebase.google.com/docs/functions/get-started?gen=2nd&hl=ko#about_this_tutorial
[REQUIRED] Expected behavior
No error should have occured
[REQUIRED] Actual behavior
When I run firebase emulators:start
i emulators: Starting emulators: functions, firestore
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage
i firestore: Firestore Emulator logging to firestore-debug.log
✔ firestore: Firestore Emulator UI websocket is running on
9150.
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions...
✔ functions: Using node@18 from host.
⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine
backend specification
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/
│
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI
│
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500, 9150
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
When I run firebase emulators:start --debug
firebase emulators:start --debug
[2023-05-24T00:10:55.555Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-05-24T00:10:55.556Z] > authorizing via signed-in user (sunwu5678@gmail.com)
[2023-05-24T00:10:55.604Z] openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1)
[2023-05-24T00:10:55.605Z] OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1, mixed mode, sharing)
[2023-05-24T00:10:55.608Z] Parsed Java major version: 11
i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[2023-05-24T00:10:55.614Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-05-24T00:10:55.620Z] [hub] writing locator at /tmp/hub-nodejs-a4db9.json
[2023-05-24T00:10:55.625Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mauth, database, hosting, pubsub, storage\u001b[22m"}}
[2023-05-24T00:10:55.627Z] defaultcredentials: writing to file /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json
[2023-05-24T00:10:55.628Z] Setting GAC to /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /home/sunwu/.config/firebase/sunwu5678_gmail_com_application_default_credentials.json"}}
[2023-05-24T00:10:55.631Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig [none]
[2023-05-24T00:10:56.042Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig 200
[2023-05-24T00:10:56.042Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/nodejs-a4db9/adminSdkConfig {"projectId":"nodejs-a4db9","storageBucket":"nodejs-a4db9.appspot.com"}
[2023-05-24T00:10:56.077Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-05-24T00:10:56.077Z] Ignoring unsupported arg: single_project_mode_error {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: single_project_mode_error"}}
[2023-05-24T00:10:56.077Z] Starting Firestore Emulator with command {"binary":"java","args":["-Djava.net.preferIPv4Stack=true","-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/home/sunwu/.cache/firebase/emulators/cloud-firestore-emulator-v1.17.4.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","nodejs-a4db9","--rules","/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {"binary":"java","args":["-Djava.net.preferIPv4Stack=true","-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/home/sunwu/.cache/firebase/emulators/cloud-firestore-emulator-v1.17.4.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","nodejs-a4db9","--rules","/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2023-05-24T00:10:57.195Z] May 24, 2023 9:10:57 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://127.0.0.1:9150
{"metadata":{"emulator":{"name":"firestore"},"message":"May 24, 2023 9:10:57 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://127.0.0.1:9150\n"}}
[2023-05-24T00:10:57.291Z] API endpoint: http://127.0.0.1:8080
{"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://127.0.0.1:8080\n"}}
[2023-05-24T00:10:57.292Z] If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
Dev App Server is now running.
{"metadata":{"emulator":{"name":"firestore"},"message":"If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080\n\nDev App Server is now running.\n\n"}}
✔ firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}
[2023-05-24T00:10:57.362Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-05-24T00:10:57.363Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2023-05-24T00:10:57.364Z] Starting Emulator UI with command {"binary":"node","args":["/home/sunwu/.cache/firebase/emulators/ui-v1.11.6/server/server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {"binary":"node","args":["/home/sunwu/.cache/firebase/emulators/ui-v1.11.6/server/server.js"],"optionalArgs":[],"joinArgs":false}"}}
i ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2023-05-24T00:10:57.486Z] Web / API server started at 127.0.0.1:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4000\n"}}
i functions: Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions..."}}
[2023-05-24T00:10:57.657Z] Validating nodejs source
[2023-05-24T00:10:58.198Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"firebase-functions-test": "^3.1.0"
},
"private": true
}
[2023-05-24T00:10:58.203Z] Building nodejs source
[2023-05-24T00:10:58.204Z] Failed to find version of module node: reached end of search path /mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules
✔ functions: Using node@18 from host.
[2023-05-24T00:10:58.215Z] Could not find functions.yaml. Must use http discovery
[2023-05-24T00:10:58.240Z] Found firebase-functions binary at '/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules/.bin/firebase-functions'
[2023-05-24T00:11:02.712Z] Serving at port 8528
[2023-05-24T00:11:16.857Z] shutdown requested via /__/quitquitquit
⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification"}}
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/ │
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500, 9150
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files
My project Structure
The text was updated successfully, but these errors were encountered: