Skip to content

Failed to load function definition from source - functions emulator fails to start or deploy fails #6285

Description

@james-dellow

[REQUIRED] Environment info

firebase-tools: 12.4.8

Platform: Windows 11 (all updates applied), Node v16.13.0

[REQUIRED] Test case

Sorry, I'm unable to provide an MCVE.

[REQUIRED] Steps to reproduce

Note: This issue is occurring intermittently over the last few days.

Running either firebase deploy or firebase emulators:start results in either the deploy failing or the functions emulators doesn't start, or sometime not all functions are available. Error reported by the CLI is:

!! functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification

However, re-running the command again and it usually works ok on the second attempt.

[REQUIRED] Expected behavior

All functions run in the emulator or the deploy doesn't fail on first attempt.

[REQUIRED] Actual behavior

I've attached the full log for a failed emulator startup, as that's the only one I've been able to capture today, but this may be the relevant section:

[2023-08-21T12:33:42.975Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"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": "16"
},
"main": "index.js",
"dependencies": {
"atlassian-jwt": "^2.0.2",
"dayjs": "^1.11.7",
"express-validator": "^6.15.0",
"firebase-admin": "^11.10.1",
"firebase-functions": "^4.4.1",
"nanoid": "^3.3.4",
"node-forge": "^1.3.1"
},
"devDependencies": {
"eslint": "^8.36.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-promise": "^6.1.1"
},
"private": true
}
[2023-08-21T12:33:42.977Z] Building nodejs source
[2023-08-21T12:33:42.978Z] Failed to find version of module node: reached end of search path C:\Users\MYUSERNAME\documents\my-app\functions\node_modules

  • functions: Using node@16 from host.
    [2023-08-21T12:33:42.986Z] Could not find functions.yaml. Must use http discovery
    [2023-08-21T12:33:43.011Z] Found firebase-functions binary at 'C:\Users\MYUSERNAME\documents\my-app\functions\node_modules.bin\firebase-functions'
    Serving at port 8683

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"}}

debug.txt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions