Firebase-functions: TypeError: Cannot read property 'name' of undefined at RefBuilder.changeConstructor

Created on 24 May 2019  路  16Comments  路  Source: firebase/firebase-functions

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 [email protected] and [email protected] (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.

realtime-database node-10 tracked internally bug

Most helpful comment

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鈥檚 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鈥檚 a Legacy Event.

Internal issue reference: 134076873

All 16 comments

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Hi @jpreynat thanks for filing! This does look like an issue on our end - could you provide a quick sample of your function code? Which specific trigger are you using - onUpdate, onWrite, or onCreate?

Confirming I can reproduce this with database triggered function with Node 10 runtime. Looking into this now.

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鈥檚 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鈥檚 a Legacy Event.

Internal issue reference: 134076873

any updates on this?

Hi @julianrichie this is still in progress and is the next highest priority to fix. Thanks for your patience!

I encountered same issue on upgrading node from 6 to v10. Anyway, on node 8, it works.

This is in progress now and will be fixed in https://github.com/firebase/firebase-functions/pull/460. Thanks for everyone's patience!

This has been released in v3.0.1.

Thanks @thechenky, I will test it quickly 馃憤

And it works like a charm, thanks 馃殌

Awesome, glad it's working @jpreynat! Thanks for testing it out :)

I encountered same issue on upgrading node from 6 to v10. Anyway, on node 8, it works.

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.

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?

Setting process.env.X_GOOGLE_NEW_FUNCTION_SIGNATURE = 'true';in my index.js is not working. I also tried process.env.X_GOOGLE_NEW_FUNCTION_SIGNATURE = true;
I still get "TypeError: functions.storage.bucket(...).onFinalize is not a function"

Hey @liezl200 , I don't think your error has anything to do with the NEW_FUNCTION signature. Looks like it's a Typescript warning that there's something wrong with your code.

Try "functions.storage.object().onFinalize..." if you're listening for changes on the default bucket or "functions.storage.bucket('MYBUCKET').object().onFinalize..." if you're listening for changes on a bucket called 'MYBUCKET'.

See the docs at https://firebase.google.com/docs/functions/gcp-storage-events

Was this page helpful?
0 / 5 - 0 ratings