Skip to content

Commit

Permalink
fix(postgres): Stop using PromiseQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
uki00a committed Feb 13, 2021
1 parent 4520543 commit 60df9e8
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {IsolationLevel} from "../types/IsolationLevel.ts";
import {PostgresDriver} from "./PostgresDriver.ts";
import {PoolClient, QueryArrayResult} from "./typings.ts";
import {NotImplementedError} from "../../error/NotImplementedError.ts";
import {PromiseQueue} from "../../util/PromiseQueue.ts";

/**
* Runs queries on a single postgres database connection.
Expand Down Expand Up @@ -156,24 +155,6 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
this.isTransactionActive = false;
}

private queryQueueMap = new Map<PoolClient, PromiseQueue<QueryArrayResult>>();

/**
* TODO Remove this method.
* This method is a workaround for a concurrency problem that occurs sometimes when using [email protected].
*/
private executeQuery(connection: PoolClient, query: string, parameters: any[]) {
if (!this.queryQueueMap.has(connection)) {
const queue = new PromiseQueue<QueryArrayResult>();
this.queryQueueMap.set(connection, queue);
queue.onEmpty().then(() => {
this.queryQueueMap.delete(connection);
});
}
const queue = this.queryQueueMap.get(connection);
return queue!.add(() => connection.queryArray(query, ...parameters));
}

/**
* Executes a given SQL query.
*/
Expand All @@ -191,8 +172,7 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
let error: any | undefined;
let result: QueryArrayResult | undefined;
try {
//result = await databaseConnection.query(query, ...(parameters || []));
result = await this.executeQuery(databaseConnection, query, parameters || []);
result = await databaseConnection.queryArray(query, ...(parameters || []));
} catch (err) {
error = err;
}
Expand Down

0 comments on commit 60df9e8

Please sign in to comment.