@mikro-orm/postgresql 7.2.0-dev.2 → 7.2.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PostgreSqlConnection.d.ts +11 -0
- package/PostgreSqlConnection.js +17 -0
- package/package.json +4 -4
|
@@ -5,6 +5,17 @@ import { AbstractSqlConnection } from '@mikro-orm/sql';
|
|
|
5
5
|
/** PostgreSQL database connection using the `pg` driver. */
|
|
6
6
|
export declare class PostgreSqlConnection extends AbstractSqlConnection {
|
|
7
7
|
createKyselyDialect(overrides: PoolConfig): PostgresDialect;
|
|
8
|
+
/**
|
|
9
|
+
* Keeps a connection dropped by the server from taking the process down. `pg` reports such a drop
|
|
10
|
+
* as an `'error'` event, and an `'error'` event without a listener is a fatal uncaught exception.
|
|
11
|
+
*
|
|
12
|
+
* Both of the paths that emit one are unguarded by default: `pg-pool` removes its own listener
|
|
13
|
+
* from a client while that client is checked out, deliberately leaving errors to whoever holds it,
|
|
14
|
+
* and it re-emits errors of idle clients on the pool itself. The query in flight still rejects on
|
|
15
|
+
* its own, so there is nothing to do here beyond logging — the pool has already discarded the
|
|
16
|
+
* broken client by the time we see it.
|
|
17
|
+
*/
|
|
18
|
+
private handlePoolErrors;
|
|
8
19
|
mapOptions(overrides: PoolConfig): PoolConfig;
|
|
9
20
|
callRoutine<T>(routine: Routine, args?: Record<string, unknown>, ctx?: Transaction): Promise<T>;
|
|
10
21
|
private fetchRefcursors;
|
package/PostgreSqlConnection.js
CHANGED
|
@@ -9,6 +9,7 @@ export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
|
9
9
|
const { onPoolCreated, ...poolOverrides } = (overrides ?? {});
|
|
10
10
|
const options = this.mapOptions(poolOverrides);
|
|
11
11
|
const pool = new Pool(options);
|
|
12
|
+
this.handlePoolErrors(pool);
|
|
12
13
|
void onPoolCreated?.(pool);
|
|
13
14
|
return new PostgresDialect({
|
|
14
15
|
pool,
|
|
@@ -17,6 +18,22 @@ export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
|
17
18
|
onReserveConnection: this.options.onReserveConnection ?? this.config.get('onReserveConnection'),
|
|
18
19
|
});
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Keeps a connection dropped by the server from taking the process down. `pg` reports such a drop
|
|
23
|
+
* as an `'error'` event, and an `'error'` event without a listener is a fatal uncaught exception.
|
|
24
|
+
*
|
|
25
|
+
* Both of the paths that emit one are unguarded by default: `pg-pool` removes its own listener
|
|
26
|
+
* from a client while that client is checked out, deliberately leaving errors to whoever holds it,
|
|
27
|
+
* and it re-emits errors of idle clients on the pool itself. The query in flight still rejects on
|
|
28
|
+
* its own, so there is nothing to do here beyond logging — the pool has already discarded the
|
|
29
|
+
* broken client by the time we see it.
|
|
30
|
+
*/
|
|
31
|
+
handlePoolErrors(pool) {
|
|
32
|
+
pool.on('connect', client => {
|
|
33
|
+
client.on('error', e => this.logger.warn('info', `PostgreSQL connection error: ${e.message}`));
|
|
34
|
+
});
|
|
35
|
+
pool.on('error', e => this.logger.warn('info', `PostgreSQL pool error: ${e.message}`));
|
|
36
|
+
}
|
|
20
37
|
mapOptions(overrides) {
|
|
21
38
|
const ret = { ...this.getConnectionOptions() };
|
|
22
39
|
const pool = this.config.get('pool');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
|
-
"version": "7.2.0-dev.
|
|
3
|
+
"version": "7.2.0-dev.4",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.2.0-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.2.0-dev.4",
|
|
51
51
|
"kysely": "0.29.4",
|
|
52
52
|
"pg": "8.22.0",
|
|
53
53
|
"pg-cursor": "2.21.0",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"postgres-interval": "4.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@mikro-orm/core": "^7.1.
|
|
59
|
+
"@mikro-orm/core": "^7.1.11"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@mikro-orm/core": "7.2.0-dev.
|
|
62
|
+
"@mikro-orm/core": "7.2.0-dev.4"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">= 22.17.0"
|