/
issue-6699.ts
30 lines (23 loc) · 1.17 KB
/
issue-6699.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
import {Connection} from "../../../src/connection/Connection";
import {expect} from 'chai';
describe("github issues > #6699 MaxListenersExceededWarning occurs on Postgres", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [],
enabledDrivers: ["postgres"]
}));
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));
it("queries in a transaction do not cause an EventEmitter memory leak", () => Promise.all(connections.map(async connection => {
await connection.transaction(async manager => {
const queryPromises = [...Array(10)].map(
() => manager.query('SELECT pg_sleep(0.0001)')
);
const pgConnection = await manager.queryRunner!.connect();
expect(pgConnection.listenerCount('error')).to.equal(1);
// Wait for all of the queries to finish and drain the backlog
await Promise.all(queryPromises);
});
})));
});