Mongoose:拓扑被破坏 MongoError

Posted

技术标签:

【中文标题】Mongoose:拓扑被破坏 MongoError【英文标题】:Mongoose: topology was destroyed MongoError 【发布时间】:2016-12-27 13:28:46 【问题描述】:

https://github.com/keystonejs/keystone 的我们一直在我们的 e2e 测试服务器中执行以下操作,现在在 e2e 开始之前删除数据库一段时间没有问题:

mongoose.connect(mongoUri,function(err) if (!err) mongoose.connection.db.dropDatabase(function (err) mongoose.connection.close(function(err) done(err); ) ); else done(err); );

但最近(Mongoose 4.5.9)我们现在在启动时收到以下错误。有任何想法吗?我们是否需要根据最近的一些更新来调整上述 drop db 逻辑?

10:00:20:493 e2e: dropping test database Mongoose model 'index-single-done' event fired on 'Boolean' for index: key: 1 With error: topology was destroyed MongoError: topology was destroyed at Server.insert (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1312:49) at Server.insert (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\server.js:351:17) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:1018:21 at handleCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\utils.js:96:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:1697:20 at handleCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\utils.js:96:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:306:20 at commandCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1182:20) at Callbacks.flush (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:88:7) at Server.destroy (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1075:41) at Server.close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\server.js:398:17) at Db.close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:357:19) at NativeConnection.doClose (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\drivers\node-mongodb-native\connection.js:233:11) at NativeConnection.Connection._close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\connection.js:570:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\connection.js:541:11 at lib$es6$promise$$internal$$initializePromise (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\es6-promise\dist\es6-promise.js:409:9) Mongoose model 'index' event fired on 'Boolean' with error: topology was destroyed MongoError: topology was destroyed at Server.insert (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1312:49) at Server.insert (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\server.js:351:17) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:1018:21 at handleCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\utils.js:96:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:1697:20 at handleCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\utils.js:96:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:306:20 at commandCallback (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1182:20) at Callbacks.flush (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:88:7) at Server.destroy (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1075:41) at Server.close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\server.js:398:17) at Db.close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb\lib\db.js:357:19) at NativeConnection.doClose (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\drivers\node-mongodb-native\connection.js:233:11) at NativeConnection.Connection._close (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\connection.js:570:12) at C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongoose\lib\connection.js:541:11 at lib$es6$promise$$internal$$initializePromise (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\es6-promise\dist\es6-promise.js:409:9) Mongoose model 'index-single-done' event fired on 'CloudinaryImage' for index: key: 1 With error: topology was destroyed MongoError: topology was destroyed at Server.insert (C:\Users\Carlos\git\prs\keystonejs\master\node_modules\keystone\node_modules\mongodb-core\lib\topologies\server.js:1312:49) ...

【问题讨论】:

更新:现在,非常零星地,似乎在测试执行期间发生(当时没有删除数据库)。 【参考方案1】:

这原来是一个逻辑错误!奇怪的逻辑是初始化猫鼬模式模型,然后删除数据库,然后关闭数据库,然后对数据库进行正常操作。无论出于何种原因,这工作了很长时间,没有任何错误。在遇到导致上述错误的同步问题之前,某些东西的性能可能会变得更快。

【讨论】:

以上是关于Mongoose:拓扑被破坏 MongoError的主要内容,如果未能解决你的问题,请参考以下文章

Mongoose 错误:“拓扑被破坏”,有啥问题?

MongoError:拓扑被破坏sailsjs

MongoError:拓扑被破坏sailsjs

MongoError:拓扑被破坏,NODEJS

MongoError:拓扑被破坏,NODEJS

MongoError:拓扑被破坏,我该如何修复它? [复制]