Firebase cloud functions error (TypeError: Cannot read property 'data' of undefined)

Viewed 328

I have a simple cloud function running on the functions emulator:

exports.helloFirebase = functions.https.onCall((data, context) => {
    return "Hello"
})

When I call it from my firebase app, as follows...

export default {
    helloFirebase: httpsCallable(fucntions, "helloFirebase")
}

then...

functionsObj.helloFirebase()
    .then((res) => {
        console.log(res)
    })
    .catch((error) => {
        console.log("ERROR IN FUNCTIONS")
        console.log(error.message)
    })

I get an error in my cloud functions console:

!  functions: TypeError: Cannot read property 'data' of undefined
    at processBackground (C:\Users\admin\AppData\Roaming\npm\node_modules\firebase- 
    tools\lib\emulator\functionsEmulatorRuntime.js:550:24)
    at invokeTrigger (C:\Users\admin\AppData\Roaming\npm\node_modules\firebase- 
    tools\lib\emulator\functionsEmulatorRuntime.js:640:19)
    at handleMessage (C:\Users\admin\AppData\Roaming\npm\node_modules\firebase- 
    tools\lib\emulator\functionsEmulatorRuntime.js:742:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
!  Your function was killed because it raised an unhandled error.

I've tried everything to solve this issue and it's still not working. Is this a bug in the firebase admin SDK?

1 Answers

This was an issue with version 10.3.1 of firebase tools. Here's the GitHub issue.

You can fix this quickly by running:

npm update -g firebase-tools
Related