firebase-tools
firebase-tools copied to clipboard
Cloud Functions deployment with Node.js 14 runtime fails during CI, works locally
[REQUIRED] Environment info
firebase-tools: 9.16.0
Platform: GitHub action runner (both ubuntu-latest and macos-latest)
[REQUIRED] Test case
Deploying a set of Cloud Functions with the Node.js 14 runtime fails with a runtime error on optional chaining ?.
.
This only happens when running on a GitHub action runner, but it works fine on my local machine (macOS).
I have verified that these versions are installed and used on both systems:
- TypeScript: 4.3.5
- Node.js: 14.17.4
- NPM: 6.14.14
- Firebase CLI: 9.16.0
I have also tried to run the action locally with act and it fails like on the GitHub instance.
No useful logs are printed even with --debug
mode except for the trace (which points to the optional chaining as a syntax error).
Here you can see one of my public actions that failed with debug enabled: https://github.com/emilioschepis/geonotes-backend/runs/3261106553
As I said, I have no problem deploying the same code (even just cloned) with the same steps. I have verified this is an issue on all my Firebase projects and is not related to the specific one I am using.
I have tried to look around in the code, and it seems to be related to trigger parsing. I am not too sure about this. The log messages immediately before the failure are:
[2021-08-06T10:04:18.560Z] Analyzing nodejs backend spec
Error: Error occurred while parsing your function triggers.
/home/runner/work/geonotes-backend/geonotes-backend/functions/lib/handlers/createNoteActionHandler.js:11
return sendOutput({ note_id: note?.id });
^
SyntaxError: Unexpected token '.'
Thank you for your help!
[REQUIRED] Steps to reproduce
- Initialize Cloud Functions
- Set
engine
to14
and use TypeScript - Use
es2020
as the tsconfig target - Run
firebase deploy
on local machine → it deploys with no issues - Setup a CI workflow on GitHub actions, passing the FIREBASE_TOKEN env variable
- Run
firebase deploy
on runner machine → it fails with a syntax error
[REQUIRED] Expected behavior
The action runs like the local environment and is able to deploy the es2020 functions.
[REQUIRED] Actual behavior
The runner fails to deploy functions.
these days, firebase-tools updated and it can use node.js16.
how about trying to version up node.js?
Based on the error message received, it looks like the version of node
binary that is used as part of firebase deploy
isn't using version of node
that understands optional chaining.
Can you double check the version of node
binary? e.g. does something like this work?
$ node
> {}?.foo
undefined
Hi @taeold , thanks for your answer.
I initially thought that could be a problem, but running node -v
gave me a version of v14.17.4.
From what I can see, Node.js supports optional chaining by default since v14.0.0 (source)
However, just to make sure I tried your experiment, and it worked correctly.
You can see the test run where optional chaining runs fine outside of firebase deploy
:
https://github.com/emilioschepis/neates-backend/blob/test/optional-chaining/.github/workflows/test-optional-chaining.yml https://github.com/emilioschepis/neates-backend/runs/3615304532
Let me know if I can provide any more information.
I'm having this issue too on any node version from 14.0.0 up to latest.
I am having this issue consistently IF I install firebase tools NOT through npm/yarn, but either using a binary or through the firebase.tools shell script.
Having the same issue. Looks like there are some differences between binary and npm versions.
@alexleonov-tactiq Thanks for the clue and additional prompts folks. I'll see if I can reproduce the issue today.
Hi @taeold, any news on this issue? Thanks.
I have this issue consistently and can't deploy functions at all on my machine.
Strangely, I am the only person on my team with the issue. We are all using the same repo, same node version (v14.17.6, managed by nvm), using yarn and yarn.lock. I have tried uninstalling and reinstalling node modules by removing node_modules, running yarn cache clean
, and also yarn rebuild
and I have done this with three different node versions. I have globally uninstalled and reinstalled firebase-tools@latest.
fixed by upgrading node to v16.8.0
and then reinstalling firebase-tools globally:
nvm install v16.8.0
nvm use v16.8.0
npm install -g firebase-tools@latest
binaries installed by running npm install -g
seemed to persist in spite of switching node versions with nvm, so maybe this issue is the result of globally-installed binaries that are still executable via command line even when the node version has been updated?
Same issue.. Cannot deploy with optional chaining..
node -v
v16.14.0
npm -v
8.5.5
"engines": {
"node": "16"
}
@taeold Could you take another look at this when you have a chance? It seems like some folks are seeing this on Node 16 now too.
Bryan and I discussed this in the triage meeting a bit, and it seems like the underlying issue is whatever version of node is being used by CI enviorments. We could add some debug logging in the discovery step to narrow this down. Also, the prepackaged Firepit builds are using Node 12, so that may be the reason we're seeing this often - we should update that in the next major version.
For those, who still encounter this issue, this is what helped me:
I had uninstalled all versions of my firebase-tools
using:
-
npm uninstall -g firebase-tools
-
which firebase
and themrm -f <PATH_TO_FIREBASE>
and then install it again npm i -g firebase-tools
Hey @emilioschepis. 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!
Hi @taeold,
I see that the issue has the label "Needs: Author Feedback", could you clarify which kind of feedback you need? I haven't really tried deploying this again, so I don't know if the underlying issue is fixed or if support for Node.js 16+ makes this issue obsolete.
If it does, let me know and I'll close this issue. Thanks.
It appears this issue can be resolved by installing the latest firebase CLI via npm i -g firebase-tools
. Although I appreciate some folks may want to stick with the binary version.
@emilioschepis - Are you able to confirm if this is still a problem with the latest binary version of firebase-tools?
Hey @emilioschepis. 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.
@emilioschepis 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.