Skip to content

sync() does not return error when db connection is erroneous #10144

Closed

Description

@eldenpark

What are you doing?

const sequelize = new Sequelize({
  database: 'some-invalid-name' // notice here
  dialect: 'postgre',
  host: 'some-funny-string', // notice here
  operatorsAliases: false,
  password: dbConfig.password,
  pool: {
    acquire: 30000,
    idle: 10000,
    max: dbConfig.poolMax,
    min: dbConfig.poolMin,
  },
  port: dbConfig.port,
  username: dbConfig.username,
});
/* ...sequelize.import */

sequelize.sync().then(() => {
  // this succeeds even if the credentials are invalid
})
  .catch((err) => {
   // never gets here
})

What do you expect to happen?

sync() is supposed to fail. Just as authenticate() returns error, for example.

/* ... */
sequelize.authenticate()
  .then(() => {})
  .catch(() => { // the same sequelize instance gets here, just as expected })

What is actually happening?

sync() succeeds, no matter what the values of credential are.
Is it how sequelize is designed to work? I believe not. sync() should at least warn the developers if the connection could be invalid.

Dialect: postgres
Dialect version: 10.1
Database version: postgres 10.1
Sequelize version: 4.38
Tested with latest release: No (If yes, specify that version)

Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.

Activity

  1. eldenpark commented on Nov 10, 2018

    @eldenpark
    Author

    A similar observation was made in 2014, #1207

  2. added
    type: bug
    on Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions