question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'scope' of undefined -- After upgrading from mongoose 4.5.8 to 4.6.3

See original GitHub issue

I’ve spent the past 24 hours trying to upgrade from mongoose 4.5.8 to 4.6.3, with no success. In certain scenarios I am getting the above error. Here is a full stack trace from my app, though I doubt it will provide a lot more information:

TypeError: Cannot read property 'scope' of undefined at model.Object.defineProperty.get [as restrictions] (<<root-path>>\node_modules\mongoose\lib\document.js:1729:38) at <<root-path>>\<<some-module>>.js:21:32 at bound (domain.js:287:14) at runBound (domain.js:300:12) at tryCatcher (<<root-path>>\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (<<root-path>>\node_modules\bluebird\js\release\promise.js:510:31) at Promise._settlePromise (<<root-path>>\node_modules\bluebird\js\release\promise.js:567:18) at Promise._settlePromise0 (<<root-path>>\node_modules\bluebird\js\release\promise.js:612:10) at Promise._settlePromises (<<root-path>>\node_modules\bluebird\js\release\promise.js:691:18) at Async._drainQueue (<<root-path>>\node_modules\bluebird\js\release\async.js:138:16) at Async._drainQueues (<<root-path>>\node_modules\bluebird\js\release\async.js:148:10) at Immediate.Async.drainQueues [as _onImmediate] (<<root-path>>\node_modules\bluebird\js\release\async.js:17:14) at processImmediate [as _immediateCallback] (timers.js:383:17)

At some point (that I can’t locate) in the execution path, the $__ field disappears and is replaced with a field whose name is [$]__. From this point on access to any field on the model results in the above error.

Unfortunately I haven’t been able to reproduce this in an isolated environment with simple test scenarios, and I really don’t have much more information. But if someone could keep an eye out for this perhaps you can figure out what changed between these two mongoose versions that could cause this.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
TobyEaldencommented, Apr 11, 2017

I’m getting this error if I try and create a schema with a key of remove. I’m currently using 4.9.4.

0reactions
vkarpov15commented, Oct 7, 2019

@davidgolden can you please open up a separate issue and follow the issue template please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - TypeError: Cannot read property 'Symbol(mongoose ...
TypeError : Cannot read property 'Symbol(mongoose#Document#scope)' of undefined at Model. set [as collection] (/Users/sama/Desktop/spbackend/ ...
Read more >
cannot read properties of undefined (reading 'split') mongoose
This bug occurs when I run my project using "npm run start:dev" in the CMD prompt. The error is trapped (see previous) and...
Read more >
mongoose | Yarn - Package Manager
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports Node.js and Deno (alpha).
Read more >
Cannot read property scope of undefined - Treehouse
Cannot read property scope of undefined. I'm getting an error when I run this project. Here is the stack trace. TypeError: Cannot read ......
Read more >
backend/node_modules/mongoose/History.md - Git01Lab
fix: upgrade mongodb driver -> 3.5. · fix: validate nested paths on Model. · fix(populate): make doc. · fix(model): return validation errors when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found