mongo-migrate-ts icon indicating copy to clipboard operation
mongo-migrate-ts copied to clipboard

Error: Connection Timed Out

Open arcenojackson opened this issue 10 months ago • 0 comments

Hi there! We have a problem running the migration commands. With "status" command, we have the response but followed by error. With other commands, we only get the error:

CONNECT ERROR: 
connection timed out
/home/developer/www/dcloud-main/node_modules/mongoose/lib/connection.js:834
  const serverSelectionError = new ServerSelectionError();

The error points to mongoose connection and with some "console.logs" I saw that it is a "connection timed out". If I comment out the line that return the reject(error), everything works great (Mongoose version: 6.6.3)

client.connect((error) => {
      if (error) {
        console.log('CONNECT ERROR: ');
        console.log(error.message);
        return reject(error);
      }

      _setClient(_this, client, options, dbName);

      for (const db of this.otherDbs) {
        console.log('DB: ');
        console.log(db)
        _setClient(db, client, {}, db.name);
      }

      resolve(_this);
    });

Our mongo-migrate-ts config file (mongo-migrate-ts version: 1.4.0):

mongoMigrateCli({
  uri: '',
  database: '',
  migrationsDir: './migrations',
  migrationsCollection: 'changeCollections',
  useEnv: true,
  environment: {
    uriVar: 'MONGODB_URI',
    databaseVar: '',
  },
  options: {
    serverSelectionTimeoutMS: 45000,
    socketTimeoutMS: 45000,
    keepAlive: true,
    retryReads: true,
    retryWrites: true,
  },
});

arcenojackson avatar Apr 04 '24 13:04 arcenojackson