firebase-functions: TypeError: Cannot read property 'name' of undefined at RefBuilder.changeConstructor
Related issues
None really.
[REQUIRED] Version info
node:
v10.15.3
firebase-functions:
2.3.0
firebase-tools:
6.10.0
firebase-admin:
7.3.0
[REQUIRED] Test case
Deploy a database trigger on Node 10 runtime and make it run by updating the database.
[REQUIRED] Steps to reproduce
Same as above.
[REQUIRED] Expected behavior
I just tested upgrading our functions from Node 8 to Node 10. I expected the transition to go smoothly.
[REQUIRED] Actual behavior
Everything is working fine locally with firebase-tools@6.10.0
and firebase-functions-test@0.16.0
(which works like a charm ATM, and is way faster than the previous emulator).
Deploying is working great too.
But the functions crash with the following logs:
Function execution took 8021 ms, finished with status: 'error'
TypeError: Cannot read property 'name' of undefined at RefBuilder.changeConstructor (/srv/functions/node_modules/firebase-functions/lib/providers/database.js:117:85)
at cloudFunctionNewSignature (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:119:34)
at cloudFunction (/srv/functions/node_modules/firebase-functions/lib/cloud-functions.js:151:20)
at Promise.resolve.then (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28)
at process._tickCallback (internal/process/next_tick.js:68:7)
Were you able to successfully deploy your functions?
Some of our ~60 functions failed to deploy, but not more than the usual number, and not the ones that were tested.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 18 (7 by maintainers)
Figured out the issue. There is a fork in our logic for massaging the raw event that comes in on the wire. We are looking for
X_GOOGLE_NEW_FUNCTION_SIGNATURE
environment variable and are expecting it to be set to true, since Node 8 started setting that. This is how we figure out whether it’s a new Event or a Legacy Event. Node 10 events are not legacy, but because that env var is missing, we are treating the raw data as if it’s a Legacy Event.Internal issue reference: 134076873
Thanks for the help. I had to rollback from vers. 10 to vers 8 and then it worked. After the warning sent by google / firebase via email that I need to upgrade from 6, I did the upgrade to vers. 10 and noticed only after 1 month that some of my notification did not work. 👎 Did not check the logs…did not get any error on firebase deploy command.
So I hat to rollback to vers 8: Set the version in the engines field in the package.json file that was created in your functions/ directory during initialization. For example, to use only version 8, edit this line in package.json: “engines”: {“node”: “10”} - not working. “engines”: {“node”: “8”}
Hope this bug will be fixed in the vers 10 (release) not BETA.
Confirming I can reproduce this with database triggered function with Node 10 runtime. Looking into this now.
It’s now late May and I find that I still have to set process.env.X_GOOGLE_NEW_FUNCTION_SIGNATURE = ‘true’; in order for my functions to work in Node 10 (which is still it seems only in beta despite the mail bombing from Google about updating). Surely this should be resolved by now?
Awesome, glad it’s working @jpreynat! Thanks for testing it out 😃
And it works like a charm, thanks 🚀