Skip to content

TypeError: entry.toJSON is not a function #1102

@deepak786

Description

@deepak786

Getting the below error in the trigger functions.auth.user().onDelete

TypeError: entry.toJSON is not a function
   at /workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:70
   at Array.map (<anonymous>) 
   at Object.record.toJSON (/workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:49)
   at JSON.stringify (<anonymous>) 
   at onUserDeleted (/workspace/user_deleted/index.js:13:59) 
   at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:135:23)
   at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:144:25
   at processTicksAndRejections (internal/process/task_queues.js:97:5) 

cloud function trigger

exports.goodByeUser = functions.auth.user().onDelete((user) => {
  console.log(`deleting data of user ${JSON.stringify(user)}`); // this JSON.stringify gives the error
});

package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "aws-sdk": "^2.658.0",
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "currencyformatter.js": "^2.2.0",
    "express": "^4.17.1",
    "firebase-admin": "^10.2.0",
    "firebase-functions": "^3.21.0",
    "jsonexport": "^3.0.1",
    "moment": "^2.24.0",
    "nanoid": "^3.0.2",
    "request": "^2.88.0"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1"
  },
  "private": true,
  "engines": {
    "node": "12"
  }
}

This was working fine with the below configuration:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "aws-sdk": "^2.658.0",
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "currencyformatter.js": "^2.2.0",
    "express": "^4.17.1",
    "firebase-admin": "^9.11.0",
    "firebase-functions": "^3.14.1",
    "jsonexport": "^3.0.1",
    "moment": "^2.24.0",
    "nanoid": "^3.0.2",
    "request": "^2.88.0"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1"
  },
  "private": true,
  "engines": {
    "node": "10"
  }
}

I updated the firebase-admin and firebase-functions dependencies and updated the Node environment to 12.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions