mongoose: Cannot assign to read only property 'remove' of object '[object Array]'
I’m using MongoDB 3.6.4 Community, NodeJS 8.9.4 and Mongoose 5.0.17, on Windows 10 Professional
From time to time the following stack trace shows on console, stopping the application:
F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\utils.js:132
throw err;
^
TypeError: Cannot assign to read only property 'remove' of object '[object Array]'
at new MongooseDocumentArray (F:\Proj1\node_modules\mongoose\lib\types\documentarray.js:45:20)
at DocumentArray.cast (F:\Proj1\node_modules\mongoose\lib\schema\documentarray.js:274:13)
at DocumentArray.SchemaType.getDefault (F:\Proj1\node_modules\mongoose\lib\schematype.js:671:23)
at $__applyDefaults (F:\Proj1\node_modules\mongoose\lib\document.js:298:22)
at model.Document (F:\Proj1\node_modules\mongoose\lib\document.js:118:3)
at model.Model (F:\Proj1\node_modules\mongoose\lib\model.js:62:12)
at new model (F:\Proj1\node_modules\mongoose\lib\model.js:3776:13)
at Object.createModel (F:\Proj1\node_modules\mongoose\lib\queryhelpers.js:106:10)
at completeMany (F:\Proj1\node_modules\mongoose\lib\query.js:1467:22)
at cb (F:\Proj1\node_modules\mongoose\lib\query.js:1328:11)
at result (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\utils.js:414:17)
at executeCallback (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\utils.js:406:9)
at handleCallback (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\utils.js:128:55)
at self.close (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\cursor.js:904:60)
at handleCallback (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\utils.js:128:55)
at completeClose (F:\Proj1\node_modules\mongoose\node_modules\mongodb\lib\cursor.js:1043:14)
Waiting for the debugger to disconnect...
Is it a bug? It doesn’t trace back to any of my project files.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15
Commits related to this issue
- test(document): repro #6431 — committed to Automattic/mongoose by vkarpov15 6 years ago
- fix(array): use `push()` instead of `concat()` because of array subclassing quirks in node v4 and v5 Re: #6431 — committed to Automattic/mongoose by vkarpov15 6 years ago
express is superfluous, this can be replicated with just mongoose and lighthouse:
6431.js
Outputs: