-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: closing pool incorrectly works on Postgres (#7596)
* fix: Promises never get resolved in specific cases (#6958) * Limit the number of query runners to remove when releasing one of them * Add while loop to release all items on the connected query runners list Closes #6958 * test: Create test for github issue #6958
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import "reflect-metadata"; | ||
import { createTestingConnections, closeTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Connection } from "../../../src/connection/Connection"; | ||
import { PostgresDriver } from "../../../src/driver/postgres/PostgresDriver"; | ||
import { expect } from "chai"; | ||
|
||
describe("github issues > #6958 Promises never get resolved in specific cases", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
enabledDrivers: ["postgres"], | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should release all used query runners upon disconnection", () => Promise.all(connections.map(async connection => { | ||
const runner1 = connection.createQueryRunner(); | ||
await runner1.query("SELECT 1 as foo;"); // dummy query to ensure that a database connection is established | ||
const runner2 = connection.createQueryRunner(); | ||
await runner2.query("SELECT 2 as foo;"); | ||
|
||
await connection.close(); | ||
|
||
expect(runner1.isReleased).to.be.true; | ||
expect(runner2.isReleased).to.be.true; | ||
expect((connection.driver as PostgresDriver).connectedQueryRunners.length).to.equal(0); | ||
}))); | ||
}); |