Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine warning and timeout #83

Open
gppleton-platform opened this issue Jun 13, 2022 · 6 comments
Open

Engine warning and timeout #83

gppleton-platform opened this issue Jun 13, 2022 · 6 comments

Comments

@gppleton-platform
Copy link

$ migrate up
(node:611) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Synchronizing database with file system migrations...
Failed to run migration AssetTableAddTypeField due to an error.
Not continuing. Make sure your data is in consistent state
Operation `rooms.find()` buffering timed out after 10000ms

This is my first time trying to use this library. Since we don't handle the connection ourselves I'm not sure how to fix the warning. And I have no idea as to why my simple find() operation is timing out. The migration table was created just fine within the collection.

I've set MIGRATE_dbConnectionUri=mongodb://mongodb:27017/diageo

@slampazona
Copy link

Same error here ... And the "migration" collection is created so the connection is OK

@dominikmch
Copy link

dominikmch commented Sep 28, 2022

Had the same issue today. It was because migrate-mongoose script wanted to access schemas before it connected to the DB. For me, adding mongoose.connect(MONGO_URI); at top of the migration script helped.

@slampazona
Copy link

Yep @dominikmch , i have used this same workaround. But i must add it on every migration scripts :/

Like this :

async function up() {
  await connectDB();
  await asyncForEach(users, async (user) => {
    await User.create({
      ...user,
      token: token(),
      origin: 'migrationScript',
    });
  });
}

/**
 * Make any changes that UNDO the up function side effects here (if possible)
 */
async function down() {
  await connectDB();
  // Write migration here
  await User.deleteMany({ origin: 'migrationScript' });
}

I noticed that only happen with import use, i have antoher project with only require and i dont have this issue.

@farmergaetano
Copy link

@balmasi, could we add the useUnifiedTopology: true connection option in the Migrator constructor (in src/lib.js) as per this answer? I've tested locally and it removes the warning.

@moonninja
Copy link

moonninja commented Oct 2, 2023

This happens when you pull User directly from you user.model.js file, use the index.js example as in the setup documentation and pull User from there, this makes a db connection before trying to do anything. Will work

`const {User} = require('../database/models/index.js')

/**

  • Make any changes you need to make to the database here
    */
    async function up () {
    await User.create({ firstName: 'user1'});
    await User.create({ firstName: 'user2'});
    }

/**

  • Make any changes that UNDO the up function side effects here (if possible)
    */
    async function down () {

}

module.exports = { up, down };`

@mariuspopaadrian
Copy link

@balmasi, could we add the useUnifiedTopology: true connection option in the Migrator constructor (in src/lib.js) as per this answer? I've tested locally and it removes the warning.

useUnifiedTopology seems to be deprecated https://www.mongodb.com/community/forums/t/mongodb-nodejs-driver-6-0-0-released/241691#usenewurlparser-and-useunifiedtopology-emit-deprecation-warnings-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants