Sails 1 - Consistency violation: Attempting to tear down a datastore (`default`) which is not currently registered with this adapter

Viewed 1606

I'm getting the following error when lifting a sails 1 app:

Consistency violation: Attempting to tear down a datastore (default) which is not currently registered with this adapter. This is usually due to a race condition in userland code (e.g. attempting to tear down the same ORM instance more than once), or it could be due to a bug in this adapter.

I have absolutely no clue what this error means. This is how my config files look like:

Category.js (Model)

module.exports = {
    schema: true,
    attributes: {
        name: {
            type: 'string',
            required: true,
            unique: true
        },
        products: {
            collection: 'product',
            via: 'category'
        },
        parentCategory: {
            model: 'category',
            defaultsTo: null
        },
        ancestors: {
            type: 'json',
            columnType: 'array',
            defaultsTo: []
        }
    }
};

datastores.js

module.exports.datastores = {
default: {

    adapter: require('sails-mongo'),
    host: 'localhost',
    port: 27017,
    // user: 'username',
    // password: 'password',
    database: 'your_mongo_db_name_here'

}


};

package.json

{
    "name": "mag",
    "private": true,
    "version": "2.0.0",
    "description": "site admin with modules",
    "keywords": [],
    "dependencies": {
        "@uirouter/angularjs": "^1.0.5",
        "angular": "^1.6.5",
        "angular-cookies": "^1.6.5",
        "angular-sanitize": "^1.6.5",
        "angular-ui-bootstrap": "^2.5.0",
        "async": "2.0.1",
        "babel-cli": "^6.24.1",
        "babel-core": "^6.25.0",
        "babel-loader": "^7.1.1",
        "babel-preset-es2015": "^6.24.1",
        "bcrypt": "^0.8.7",
        "bootstrap": "^3.3.7",
        "bootstrap-loader": "^2.1.0",
        "fs-extra": "^0.30.0",
        "imports-loader": "^0.7.1",
        "jquery": "1.11.0",
        "jsonwebtoken": "^5.5.4",
        "lodash": "3.10.1",
        "ng-lodash": "^0.2.3",
        "ng-toast": "^2.0.0",
        "resolve-url-loader": "^2.1.0",
        "sails": "^1.0.0-36",
        "sails-disk": "^0.10.10",
        "sails-hook-babel": "^6.0.3",
        "sails-hook-orm": "^2.0.0-0",
        "sails-hook-sockets": "^1.0.1",
        "sails-mongo": "^1.0.0-9",
        "style-loader": "^0.18.2",
        "url-loader": "^0.5.9",
        "webpack": "2.2.1"
    },
    "devDependencies": {
        "babel-preset-env": "^1.6.0",
        "clean-webpack-plugin": "0.1.16",
        "copy-webpack-plugin": "4.0.1",
        "css-loader": "^0.27.3",
        "ejs-loader": "0.3.0",
        "extract-text-webpack-plugin": "2.1.0",
        "less": "2.7.2",
        "less-loader": "4.0.1",
        "sails.io.js": "1.1.9",
        "socket.io-client": "1.7.3"
    },
    "scripts": {
        "start": "NODE_ENV=production node app.js"
    },
    "main": "app.js",
    "author": "",
    "license": ""
}

any hint??

1 Answers

Got this error because in my User.js model, i referred to a post collection model which i had not created at the time i tried to lift my sails app

posts : { collection : 'post', via : 'owner' },

Solved the problem by commenting it out. Apparently, there are many possible reasons one could get this error. Do well to look closely at the entire stack trace - that was where i found my mistake. Hope this helps.

Related