pg-cache 3.30.6 → 3.30.7
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/esm/pg.js +23 -0
- package/package.json +2 -2
- package/pg.js +23 -0
package/esm/pg.js
CHANGED
|
@@ -84,6 +84,29 @@ export const defaultPgPoolFactory = (pgConfig) => {
|
|
|
84
84
|
log.error(`Pool ${database} unexpected idle connection error [${err.code || 'unknown'}]: ${err.message}`);
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
|
+
/**
|
|
88
|
+
* Client-level error handler for checked-out connections.
|
|
89
|
+
*
|
|
90
|
+
* The pool handler above covers idle clients only: pg-pool removes its own
|
|
91
|
+
* listener while a client is checked out (a request's transaction, a schema
|
|
92
|
+
* introspection). When the server ends such a connection (a restart, a
|
|
93
|
+
* failover, pg_terminate_backend), pg rejects the query in flight AND emits
|
|
94
|
+
* 'error' on the client itself. With no listener that event is fatal: the
|
|
95
|
+
* whole process exits, dropping every other request. PostGraphile adds this
|
|
96
|
+
* listener to pools it creates and leaves it to callers that pass their own
|
|
97
|
+
* pool, as the GraphQL server does with this one.
|
|
98
|
+
*
|
|
99
|
+
* This listener only keeps the process alive; it does not swallow anything.
|
|
100
|
+
* The owner still sees the error through the rejected query (and any later
|
|
101
|
+
* query on that client), and the pool discards the broken client when it is
|
|
102
|
+
* released. An idle client's error also reaches the pool handler above, so
|
|
103
|
+
* this one logs at debug level instead of reporting it twice.
|
|
104
|
+
*/
|
|
105
|
+
pgPool.on('connect', (client) => {
|
|
106
|
+
client.on('error', (err) => {
|
|
107
|
+
log.debug(`Pool ${database} client connection error [${err.code || 'unknown'}]: ${err.message}`);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
87
110
|
return pgPool;
|
|
88
111
|
};
|
|
89
112
|
export const getPgPool = (pgConfig) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-cache",
|
|
3
|
-
"version": "3.30.
|
|
3
|
+
"version": "3.30.7",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL connection pool LRU cache manager",
|
|
6
6
|
"main": "index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"lru-cache": "^11.2.7",
|
|
24
24
|
"pg": "^8.21.0",
|
|
25
|
-
"12factor-env": "^1.34.1",
|
|
26
25
|
"@pgpmjs/logger": "^2.27.1",
|
|
27
26
|
"@pgpmjs/types": "^2.58.6",
|
|
27
|
+
"12factor-env": "^1.34.1",
|
|
28
28
|
"pg-env": "^1.33.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/pg.js
CHANGED
|
@@ -92,6 +92,29 @@ const defaultPgPoolFactory = (pgConfig) => {
|
|
|
92
92
|
log.error(`Pool ${database} unexpected idle connection error [${err.code || 'unknown'}]: ${err.message}`);
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
|
+
/**
|
|
96
|
+
* Client-level error handler for checked-out connections.
|
|
97
|
+
*
|
|
98
|
+
* The pool handler above covers idle clients only: pg-pool removes its own
|
|
99
|
+
* listener while a client is checked out (a request's transaction, a schema
|
|
100
|
+
* introspection). When the server ends such a connection (a restart, a
|
|
101
|
+
* failover, pg_terminate_backend), pg rejects the query in flight AND emits
|
|
102
|
+
* 'error' on the client itself. With no listener that event is fatal: the
|
|
103
|
+
* whole process exits, dropping every other request. PostGraphile adds this
|
|
104
|
+
* listener to pools it creates and leaves it to callers that pass their own
|
|
105
|
+
* pool, as the GraphQL server does with this one.
|
|
106
|
+
*
|
|
107
|
+
* This listener only keeps the process alive; it does not swallow anything.
|
|
108
|
+
* The owner still sees the error through the rejected query (and any later
|
|
109
|
+
* query on that client), and the pool discards the broken client when it is
|
|
110
|
+
* released. An idle client's error also reaches the pool handler above, so
|
|
111
|
+
* this one logs at debug level instead of reporting it twice.
|
|
112
|
+
*/
|
|
113
|
+
pgPool.on('connect', (client) => {
|
|
114
|
+
client.on('error', (err) => {
|
|
115
|
+
log.debug(`Pool ${database} client connection error [${err.code || 'unknown'}]: ${err.message}`);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
95
118
|
return pgPool;
|
|
96
119
|
};
|
|
97
120
|
exports.defaultPgPoolFactory = defaultPgPoolFactory;
|