forked from coopernurse/node-pool
-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Hi I faced with issue of closing connecting to db after calling of sequelize.close().
You can find below example of source code with reproducing this issue.
I also prepared pull request #8 that fix this issue, please review it.
const Sequelize = require('sequelize');
process.on('exit', () => {
console.log('process.on exit');
});
const sequelize = new Sequelize('mysql://user:pass@localhost:3306/dbname', {
dialect: 'mysql',
});
async function cleanDB() {
await sequelize.authenticate();
console.log('DB connection successfully established');
return sequelize.transaction(async t => {
const options = {
transaction: t,
};
await sequelize.query('SELECT 1+1', options);
console.log('Query was processed successfully');
});
}
cleanDB()
.then(() => {
console.log('cleanDB finish successfully ');
})
.catch(err => {
console.log('cleanDB throw error => ', err);
})
.finally(() => {
sequelize
.close()
.then(() => {
console.log('Connection has been close successfully.');
})
.catch(err => {
console.error('Unable to close connect to the database:', err);
});
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels