Repository navigation
Description
[REQUIRED] Environment info
firebase-tools:
13.7.0
Platform:
macOS
Sonoma 14.4.1
[REQUIRED] Test case
Right after upgrading to firebase-tools v13.7.0, the emulators started showing the error Trying to construct a python runtime delegate for runtime nodejs20 on start. I'm testing a function on Python 3.12, and I noticed it works when I add "runtime": "python312" on firebase.json as per the documentation.
But this was never required before.
[REQUIRED] Steps to reproduce
- Create a blank function from scratch with
firebase init, choosing "Functions" and "Emulators" as features and Python as language. Using an existing project or a new one is irrelevant, but everything else can be left as default in the rest of the process; - Runing
firebase emulators:startafter firebase finished creating the function will give the aforementioned error message; - You have to manually add the
"runtime": "python312"on firebase.json; - Run
firebase emulators:startagain and then it will load your function correctly.
Here are some evidences of the fail case without the runtime info on firebase.json, and the success case after I added it:
No runtime on firebase.json (out of the box)
With runtime on firebase.json (manually added)
[REQUIRED] Expected behavior
I noticed the runtime validation was just introduced in this line from this commit, but maybe it would be reasonable if the runtime config could be either automatically inferred from firebase init when we select the function language, or at least prompted to be selected by ourselves from the list of supported runtimes.
In any case, not everybody is expected to know right away that they have to manually add this information on firebase.json, let alone find a Stackoverflow answer for a newly created error message.
[REQUIRED] Actual behavior
Running firebase:emulators start --debug gives the following log at the end:
i ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2024-04-05T04:27:26.600Z] 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"}}
[2024-04-05T04:27:26.600Z] Web / API server started at ::1:4000
{"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4000\n"}}
i functions: Watching "/Users/xxxxx/test-function/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/xxxxx/test-function/functions\" for Cloud Functions..."}}
[2024-04-05T04:27:26.785Z] Customer code is not Node
⬢ functions: Failed to load function definition from source: FirebaseError: Internal error. Trying to construct a python runtime delegate for runtime nodejs20 {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Internal error. Trying to construct a python runtime delegate for runtime nodejs20"}}


Activity
[-]Version 13.7.0 now requires manually adding "runtime" value in firebase.json[/-][+]Version 13.7.0 now requires manually adding "runtime" configuration in firebase.json[/+]amfc commentedon Apr 5, 2024
I think this also applies to nodejs:
I just just upgraded (npm i -g firebase-tools) and started receiving:
functions: Your requested "node" version "20" doesn't match your global version "18". Using node@18 from host.
even though I have node version 18 in package.json
by setting functions: { runtime: "nodejs18" } in firebase.json it stopped giving the warning.
aalej commentedon Apr 5, 2024
Hey @vitoras, thanks for the thorough report as well as for sharing your observations, and thanks @amfc for the additional information. I was able to reproduce the issue. It looks like both Node.js and Python runtimes are affected here.
As a workaround for those who also encounter this issue, please specify the
runtimein yourfirebase.jsonfile. Here's references for setting the Node.js version and Python version. I’ll raise this to our engineering team so that we can determine what the appropriate action here would be. I’ll also mark this as reproducible.vitoras commentedon Apr 5, 2024
Yeah, this idea was raised in this issue, but maybe they overlooked that impact.
inlined commentedon Apr 5, 2024
Today's release of the CLI fixes the issue.
vitoras commentedon Apr 6, 2024
Thanks a lot, now the emulators are working as before!