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

TypeError: this.$__schema.paths[p].splitPath is not a function #10979

Closed
AbdelrahmanHafez opened this issue Nov 16, 2021 · 2 comments
Closed

Comments

@AbdelrahmanHafez
Copy link
Collaborator

AbdelrahmanHafez commented Nov 16, 2021

When we upgraded to v6 from v5 we faced the exception below seemingly randomly, we can't consistently reproduce it.
I'll try to come up with a reproduction script.

The only thing I could find related to this error is #10453 which suggests that there are two versions of mongoose, even though that's not the case for me:

$ npm ls mongoose
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
TypeError: this.$__schema.paths[p].splitPath is not a function
    at model.Document.$__buildDoc (/root/speero-backend/node_modules/mongoose/lib/document.js:645:42)
    at model.Document (/root/speero-backend/node_modules/mongoose/lib/document.js:143:10)
    at model.Model (/root/speero-backend/node_modules/mongoose/lib/model.js:106:12)
    at new model (/root/speero-backend/node_modules/mongoose/lib/model.js:4763:15)
    at /root/speero-backend/node_modules/mongoose/lib/model.js:3112:22
    at /root/speero-backend/node_modules/mongoose/lib/model.js:3148:7
    at Array.forEach (<anonymous>)
    at /root/speero-backend/node_modules/mongoose/lib/model.js:3147:15
    at /root/speero-backend/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/root/speero-backend/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/root/speero-backend/node_modules/mongoose/lib/index.js:1151:10)
    at Function.create (/root/speero-backend/node_modules/mongoose/lib/model.js:3077:23)
    at Object.checkoutCart [as checkout] (file:///root/speero-backend/src/modules/carts/functions/carts.checkout.function.js:136:54)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
@AbdelrahmanHafez AbdelrahmanHafez added the needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue label Nov 16, 2021
@AbdelrahmanHafez
Copy link
Collaborator Author

I added a log to check when splitPath is not a function, the value of this.$__schema.paths[p] is

 { instance: 'ObjectID', options: { ref: 'CoreCity' } }

@AbdelrahmanHafez AbdelrahmanHafez removed the needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue label Nov 17, 2021
@AbdelrahmanHafez
Copy link
Collaborator Author

Turns out some piece of our code was modifying the schema by adding this POJO, it's not a mongoose error.
{ instance: 'ObjectID', options: { ref: 'CoreCity' } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant