Closed francoisromain closed 5 years ago
Might be a bug. Which database are you using?
postgres
It might be caused by this line https://github.com/Vincit/knex-db-manager/blob/master/lib/PostgresDatabaseManager.js#L35
I suppose first reject should take new Error() as parameter or remove initial reject all together.
Do you have some more help how to reproduce this? I did check that there is a test running that command and there is no warnings shown anywhere.
it("#createDb should create a database", function () {
return dbManager.createDb(dbManager.config.knex.connection.database)
.then(function () {
// connecting db should work
var knex = dbManager.knexInstance();
return knex.raw('SELECT 1');
});
});
https://travis-ci.org/Vincit/knex-db-manager/jobs/570047748#L590
Yeah... I really cannot reproduce this one. It doesn't seem to be caused because of that Promise.reject() call either:
Mikaels-MacBook-Pro:tarn.js mikaelle$ cat test.js
const BB = require('bluebird');
const p = BB.reject();
async function run() {
try {
await p;
} catch (err) {
console.log("err", err);
}
}
run();
Mikaels-MacBook-Pro:tarn.js mikaelle$ node test.js
err undefined
Mikaels-MacBook-Pro:tarn.js mikaelle$
Closing as cannot reproduce for now. Lets reopen if complete reproduction case is provided.
I have the error with this script: https://github.com/MTES-MCT/camino-api/blob/8a0e28132368302e3d7663ecd81f6e9121de2e69/knex/recreate.js#L13
Let me know if you can reproduce with this. Thank you
I'll try that one đź‘Ť
Mikaels-MacBook-Pro:test mikaelle$ cat test.js
const chalk = require('chalk')
const config = {
knex: {
// just the usual knex configuration
client: 'postgres',
connection: {
host: 'localhost',
database: 'appdb',
user: 'mikaelle'
},
pool: {
min: 0,
max: 10
},
migrations: {
directory: __dirname + '/migrations'
}
},
dbManager: {
// db manager related configuration
collate: ['fi_FI.UTF-8', 'Finnish_Finland.1252'],
superUser: 'postgres'
}
};
const dbManager = require('knex-db-manager').databaseManagerFactory(config);
const run = async () => {
try {
console.log('supprime la base de données…')
await dbManager.dropDb('camino')
console.log('base de données supprimée')
console.log('')
console.log('crée la base de données…')
await dbManager.createDb('camino')
console.log('base de données créée')
console.log('')
process.exit()
} catch (e) {
console.error(chalk.red(e))
process.exit(1)
}
}
run()
Mikaels-MacBook-Pro:test mikaelle$ node test.js
supprime la base de données…
base de données supprimée
crée la base de données…
base de données créée
Mikaels-MacBook-Pro:test mikaelle$ node --version
v10.15.1
Mikaels-MacBook-Pro:test mikaelle$
Still no luck with reproduction
ok I'll try on my side. Thank you for your time.
Hello
When I run
await dbManager.createDb('my_db')
, The database is created but I get the error(node:4687) Warning: a promise was rejected with a non-error: [object Undefined]
. The instruction is in a try catch bloc.Is there anything I should do to avoid this error?
Thank you