【发布时间】:2019-07-26 04:55:06
【问题描述】:
【问题讨论】:
标签: node.js mongodb mongodb-compass
【问题讨论】:
标签: node.js mongodb mongodb-compass
Topology was destroyed 错误来了,当 mongodb 正在写东西并且连接在中间关闭/中断。
查看引发此错误的code:
Mongos.prototype.insert = function(ns, ops, options, callback) {
if(typeof options == 'function') callback = options, options = {}, options = options || {};
if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed')));
// Not connected but we have a disconnecthandler
if(!this.isConnected() && this.s.disconnectHandler != null) {
return this.s.disconnectHandler.add('insert', ns, ops, options, callback);
}
// No mongos proxy available
if(!this.isConnected()) {
return callback(new MongoError('no mongos proxy available'));
}
// Execute write operation
executeWriteOperation(this, 'insert', ns, ops, options, callback);
}
解决方案:
请重新启动您的 mongodb 和 MongoDB 指南针,以确保更安全,您应该能够创建集合而不会出现任何错误。
【讨论】: