Skip to content

Cloud function - Cannot read property 'Symbol(Symbol.iterator)' of undefined at convertValue #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
udox-cameron opened this issue Jan 11, 2018 · 15 comments
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@udox-cameron
Copy link

Hey guys,

My cloud firestone function are getting the following error whenever they are triggered, I have seen some people are getting similar error on here and the fix was to upgrade the cloud function library. Unfortunately I have upgraded to version 0.8.0 and still get the following error.

exports.cleanSubmittedUrls = functions.firestore.document('url/{urlid}').onWrite((event) =>  {
	console.log('event.data', event)
	return true;
})

package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "version": "1.0.0",
  "dependencies": {
    "cors": "2.8.3",
    "express": "4.15.3",
    "firebase-admin": "5.7.0",
    "firebase-functions": "0.8.0",
    "secure-compare": "3.0.1",
    "string": "3.3.3"
  },
  "private": true
}

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at convertValue (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/convert.js:182:44) at convertDocument (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/convert.js:226:22) at Firestore.snapshot_ (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/index.js:376:11) at dataConstructor (/user_code/node_modules/firebase-functions/lib/providers/firestore.js:100:38) at Object. (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:57:31) at next (native) at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71 at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12) at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:53:36) at /var/tmp/worker/worker.js:695:26

Thanks,
Cameron

@schmidt-sebastian schmidt-sebastian self-assigned this Jan 12, 2018
@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Jan 12, 2018

@udox-cameron Do you know if your Firestore document may contain an empty array?

If you can reproduce this, do you mind grabbing the contents of the event object via JSON.stringify(event)? Thanks.

And just to verify, the Firestore dependency you are using is 0.10.x? If you have a package-lock.json or yarn.lock, you might see an older version.

@laurentpellegrino
Copy link

laurentpellegrino commented Jan 12, 2018

@schmidt-sebastian I am getting the exact same error. The document that triggers the function that fails with the error looks as follows:

{
  "attachments": [
    
  ],
  "author": {
    "email": "x@y",
    "fullName": "z",
    "jobTitle": "w"
  },
  "content": {
    "html": "<p>Simple post content<\/p>\n",
    "htmlEscaped": "&lt;p&gt;Simple post content&lt;\/p&gt;\n",
    "markdown": "Simple post content",
    "plaintext": "Simple post content"
  },
  "createdAt": "2018-01-12T14:53:27.097Z",
  "draft": false,
  "draftLabels": {
    "lR7KSMZPgznVJRsd8F0z": 1515768805616
  },
  "excerpt": "Simple post content",
  "forwardToWebhooks": false,
  "labels": {
    "lR7KSMZPgznVJRsd8F0z": true
  },
  "orderedLabels": [
    "lR7KSMZPgznVJRsd8F0z"
  ],
  "publicationTime": "2018-01-12T14:53:00.001Z",
  "slug": "my-title",
  "title": "My title",
  "tstate": false,
  "updatedAt": "2018-01-12T14:53:34.180Z"
}

Firestore version used is 0.10.1.

@schmidt-sebastian
Copy link
Contributor

I was just able to reproduce this. It looks like for empty arrays, ProtobufJS doesn't always return the array type. Thanks for your patience.

@laurentpellegrino
Copy link

@schmidt-sebastian Great! Do you have a rough idea of the time it will take to see a public release that fixes the issue?

@udox-cameron
Copy link
Author

udox-cameron commented Jan 12, 2018

Hey,

I can't print out the error because I just get the error above. Here is the data it is working with.

{ "beaconfunctionsgroups":[], beacons":["2fUU4F8"], "campaign":"POS", "gid":"orgkey", "status":"updated", "url":"http://bfred-it.github.io/iphone-inline-video/demo/threejs.html", "visibleTime":"2018-01-12T13:49:00.000Z" }

@ghost ghost added the cla: yes This human has signed the Contributor License Agreement. label Jan 12, 2018
@ghost ghost removed the cla: yes This human has signed the Contributor License Agreement. label Jan 12, 2018
@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Jan 13, 2018

The releases for 0.10.2 and 0.11.1 contain fixes for this issue. Note that the cache on Google Cloud Functions currently still resolves firebase-admin's Firestore dependency to 0.10.1. I will notify this thread when that is no longer the case.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Jan 15, 2018

If you redeploy your Functions, you should now be able to get the newest copy from the cache and no longer see this error.

@laurentpellegrino
Copy link

laurentpellegrino commented Jan 15, 2018 via email

@laurentpellegrino
Copy link

laurentpellegrino commented Jan 15, 2018

@schmidt-sebastian Erf, I have updated the dependencies as follows:

    "firebase-admin": "5.6.0",
    "firebase-functions": "^0.8.0",

It seems that GRPC 1.8.0 is fetched. As a consequence, a lot of functions fail with the famous Error: Stream removed :(

@laurentpellegrino
Copy link

@schmidt-sebastian Reverting to firebase-admin 5.5.1 and firebase-functions 0.7.5 still fetches the new dependency! Is there a way to force the old dependency so that GRPC is not fetched? that's a big issue since it breaks all our functions at this time.

@schmidt-sebastian
Copy link
Contributor

Do you see this locally or on functions?

These are the results I get:

functions $ rm package-lock.json 

functions $ rm -rf node_modules/

functions $ npm install --save [email protected]

> [email protected] install /Users/mrschmidt/Desktop/node-review-with-fix/functions/node_modules/google-gax/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/Users/mrschmidt/Desktop/node-review-with-fix/functions/node_modules/google-gax/node_modules/grpc/src/node/extension_binary/node-v57-darwin-x64-unknown/grpc_node.node" is installed via remote

> [email protected] install /Users/mrschmidt/Desktop/node-review-with-fix/functions/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/Users/mrschmidt/Desktop/node-review-with-fix/functions/node_modules/grpc/src/node/extension_binary/node-v57-darwin-x64/grpc_node.node" is installed via remote

> [email protected] postinstall /Users/mrschmidt/Desktop/node-review-with-fix/functions/node_modules/google-gax/node_modules/protobufjs
> node scripts/postinstall

npm notice created a lockfile as package-lock.json. You should commit this file.
+ [email protected]
added 435 packages in 18.378s

functions $ npm install --save firebase-functions@^0.8.0
+ [email protected]
added 57 packages in 5.373s

functions $ npm list | grep grpc
│ │ ├─┬ @google-cloud/[email protected]
│ │ │ ├── [email protected] deduped
│ │ │ ├─┬ [email protected]
│ │ ├─┬ [email protected]

@laurentpellegrino
Copy link

laurentpellegrino commented Jan 15, 2018

@schmidt-sebastian Ah sorry, the issue seems due to firebase 4.8.2 that is also used in my setup:

├─┬ [email protected]
│ ├─┬ @firebase/[email protected]
│ │ ├── @firebase/[email protected]
│ │ └── @firebase/[email protected]
│ ├─┬ @firebase/[email protected]
│ │ └── @firebase/[email protected]
│ ├─┬ @firebase/[email protected]
│ │ ├── @firebase/[email protected]
│ │ └── [email protected]
│ ├─┬ @firebase/[email protected]
│ │ ├── @firebase/[email protected]
│ │ ├── @firebase/[email protected]
│ │ └─┬ [email protected]

I will try to downgrade to an older version. Do you know a compatible one?

@laurentpellegrino
Copy link

The dependency tree is from my local setup. The error is with deployed functions :S

@laurentpellegrino
Copy link

Using firebase 4.6.1 is fetching a compatible version of GRPC.

@schmidt-sebastian Do you think it's worth opening an issue on firebase-js-sdk?

@schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian Do you think it's worth opening an issue on firebase-js-sdk?

I will get this resolved internally.

@google-cloud-label-sync google-cloud-label-sync bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants