isMomentJsType - Cannot read property 'name' of undefined
Environment details
- OS: Linux
- Node.js version: 12.14.1
- npm version: 6.13.4
@google-cloud/firestoreversion: 3.4.0
Steps to reproduce
- Update from
@google-cloud/firestoreversion 3.3.4 - Save an array of objects? In my case I have an array of input objects coming from graphql
- 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!
@schmidt-sebastian Hey bud, just tagging you in because this relates to #879
It's interesting that you are hitting this code path. I will fix this specific error with https://github.com/googleapis/nodejs-firestore/pull/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). .
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.