不要怂,就是干,撸起袖子干!

Commit e239a04d by Nick Schultz Committed by Felix Becker

ConnectionManager.close not closing database connection completely (#7756)

* drain doesnt take a callback, it returns a promise instead

* update changelog

* add test
1 parent 99d87dff
# Next # Next
- [ADDED] `Model.increment`, to increment multiple rows at a time [#7394](https://github.com/sequelize/sequelize/pull/7394) - [ADDED] `Model.increment`, to increment multiple rows at a time [#7394](https://github.com/sequelize/sequelize/pull/7394)
- [FIXED] calling `.close` on Sequelize db instance does not properly close the connection socket [#7751](https://github.com/sequelize/sequelize/issues/7751)
# 4.0.0 (final) # 4.0.0 (final)
- [ADDED] Add `isSoftDeleted` helper method to model instance [#7408](https://github.com/sequelize/sequelize/issues/7408) - [ADDED] Add `isSoftDeleted` helper method to model instance [#7408](https://github.com/sequelize/sequelize/issues/7408)
......
...@@ -61,7 +61,7 @@ class ConnectionManager { ...@@ -61,7 +61,7 @@ class ConnectionManager {
return Promise.resolve(); return Promise.resolve();
} }
return this.pool.drain(() => { return this.pool.drain().then(() => {
debug('connection drain due to process exit'); debug('connection drain due to process exit');
return this.pool.clear(); return this.pool.clear();
}); });
......
...@@ -146,4 +146,23 @@ describe('Connection Manager', () => { ...@@ -146,4 +146,23 @@ describe('Connection Manager', () => {
}); });
}); });
it('should clear the pool after draining it', () => {
const options = {
replication: null
};
const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
connectionManager.initPools();
const poolDrainSpy = sandbox.spy(connectionManager.pool, 'drain');
const poolClearSpy = sandbox.spy(connectionManager.pool, 'clear');
return connectionManager.close().then(() => {
expect(poolDrainSpy.calledOnce).to.be.true;
expect(poolClearSpy.calledOnce).to.be.true;
});
});
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!