Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoError: topology was destroyed sailsjs

When I try to create this error shows up:

Error (E_UNKNOWN) :: Encountered an unexpected error MongoError: topology was destroyed at Server.insert (/Users/oscargallon/Documents/developer/sails/reyesmagoswebpae/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:797:49)

here's my model

module.exports = {

    attributes: {
        name: {
            type: 'string',
            required: true
        },
        email: {
            type: 'String',
            required: true
        },
        description: {
            type: 'string',
            required: true
        },
        phonenumber: {
            type: 'string',
            required: true
        },
        mobile: {
            type: 'string',
            required: true
        }
    }
};
like image 545
Oscar Gallon Avatar asked Apr 30 '15 05:04

Oscar Gallon


People also ask

What does topology destroyed mean?

Usually the topology was destroyed error message is produced when you're trying to run a db operation when you've closed the connection to the database.

What is useUnifiedTopology true?

useUnifiedTopology: False by default. Set to true to opt in to using the MongoDB driver's new connection management engine. You should set this option to true , except for the unlikely case that it prevents you from maintaining a stable connection.


2 Answers

I also encountered this same problem today - i changed the sails-mongo version from "sails-mongo": "^0.10.7" to "sails-mongo": "^0.10.6" in package.json in sails and ran $ sudo npm install then sails lift it worked fine i think there is some error in npm

like image 116
Anandapriyan S.D Avatar answered Sep 29 '22 13:09

Anandapriyan S.D


Sails-mongo v0.10.7 introduced a breaking change and doesn't support mongo <= 2.4. The breaking change has been reverted and v0.10.8 was published restoring compatibility with mongo <= 2.4. Meanwhile v0.10.7 has been deprecated.

Simultaneously v0.11 has been released which is compatible with mongo >= 2.6.

For those using mongo <= 2.4 do not update to 0.11.x.

UPDATE: some users reported problems with Mongo 3.0 and using v0.10.8 seems to have fixed the issue for them: more details.

UPDATE 2: The issue with v0.10.7 and v0.11.0-1 has been traced to inappropriate connection configurations (PR #277). This can be fixed locally by adjusting the connection config (sails/config/connections.js file for sails users):

devMongodbServer: { // connection name
    port: 27017,
    database: 'dev-mongodb-server',
    poolSize: 5,
    socketOptions: {
        noDelay: true,
        connectTimeoutMS: 0,
        socketTimeoutMS: 0
    }
}

v0.11.2 will be released with this connection config as default.

More details on https://github.com/balderdashy/sails-mongo/issues/266

like image 36
Dário Avatar answered Sep 29 '22 12:09

Dário