Skip to content
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

isMomentJsType - Cannot read property 'name' of undefined #892

Closed
zomble opened this issue Jan 22, 2020 · 3 comments · Fixed by #893
Closed

isMomentJsType - Cannot read property 'name' of undefined #892

zomble opened this issue Jan 22, 2020 · 3 comments · Fixed by #893
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API.

Comments

@zomble
Copy link

zomble commented Jan 22, 2020

Environment details

  • OS: Linux
  • Node.js version: 12.14.1
  • npm version: 6.13.4
  • @google-cloud/firestore version: 3.4.0

Steps to reproduce

  1. Update from @google-cloud/firestore version 3.3.4
  2. Save an array of objects? In my case I have an array of input objects coming from graphql
  3. TypeError: Cannot read property 'name' of undefined" at isMomentJsType /node_modules/@google-cloud/firestore/build/src/serializer.js:312:27

See https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/serializer.ts#L403
isMomentJsType appears to assume a constructor will always exist and have .name

A example dump of the value being checked inside isMomentJsType

[
  [Object: null prototype] {
    test: '123',
    quantity: 1,
    name: 'Hat'
  }
]

with value.constructor being undefined

Cheers!

@zomble
Copy link
Author

zomble commented Jan 22, 2020

@schmidt-sebastian Hey bud, just tagging you in because this relates to #879

@schmidt-sebastian
Copy link
Contributor

It's interesting that you are hitting this code path. I will fix this specific error with #893, but I would assume that with #893 merged you will now get an error about using an unsupported object type in your documents (https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/serializer.ts#L391).
.

@zomble
Copy link
Author

zomble commented Jan 22, 2020

Yes, I found it strange as well. I am digging around in graphql lib to understand why I even get the object I am getting, as it really should be a plain object.

@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
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants