relq 1.0.122 → 1.0.124
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/dist/cjs/core/pg-family/shared/pg-base.cjs +7 -1
- package/dist/cjs/core/shared/cleanup.cjs +5 -0
- package/dist/cjs/types/config-types.cjs +4 -2
- package/dist/esm/core/pg-family/shared/pg-base.js +7 -1
- package/dist/esm/core/shared/cleanup.js +5 -0
- package/dist/esm/types/config-types.js +4 -2
- package/package.json +1 -1
|
@@ -130,7 +130,13 @@ class PgBase extends relq_base_1.RelqBase {
|
|
|
130
130
|
async _query(sql) {
|
|
131
131
|
const executeQuery = async () => {
|
|
132
132
|
if (this.pool) {
|
|
133
|
-
|
|
133
|
+
const client = await this.pool.connect();
|
|
134
|
+
try {
|
|
135
|
+
return await client.query(sql);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
client.release();
|
|
139
|
+
}
|
|
134
140
|
}
|
|
135
141
|
else if (this.client) {
|
|
136
142
|
await this.ensureClientConnection();
|
|
@@ -15,6 +15,11 @@ function registerGlobalCleanupHandlers() {
|
|
|
15
15
|
return;
|
|
16
16
|
if (typeof node_process_1.default === 'undefined' || !node_process_1.default.on)
|
|
17
17
|
return;
|
|
18
|
+
try {
|
|
19
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers')
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
18
23
|
node_process_1.default.on('beforeExit', async () => {
|
|
19
24
|
if (exports.activeInstances.size === 0)
|
|
20
25
|
return;
|
|
@@ -16,6 +16,8 @@ function toPoolConfig(config) {
|
|
|
16
16
|
const port = config.aws?.port ?? config.port ?? 5432;
|
|
17
17
|
const user = config.aws?.user ?? config.user ?? (isAws ? 'admin' : undefined);
|
|
18
18
|
const ssl = isAws ? (config.aws.ssl ?? true) : config.ssl;
|
|
19
|
+
const isWorkers = typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers';
|
|
20
|
+
const allowExitOnIdle = !isWorkers;
|
|
19
21
|
const poolConfig = {
|
|
20
22
|
host,
|
|
21
23
|
port,
|
|
@@ -28,7 +30,7 @@ function toPoolConfig(config) {
|
|
|
28
30
|
connectionTimeoutMillis: config.pool?.connectionTimeoutMillis ?? smartDefaults.connectionTimeoutMillis,
|
|
29
31
|
application_name: config.pool?.application_name,
|
|
30
32
|
ssl: config.pool?.ssl ?? ssl,
|
|
31
|
-
allowExitOnIdle
|
|
33
|
+
allowExitOnIdle
|
|
32
34
|
};
|
|
33
35
|
if (config.connectionString) {
|
|
34
36
|
return {
|
|
@@ -39,7 +41,7 @@ function toPoolConfig(config) {
|
|
|
39
41
|
connectionTimeoutMillis: poolConfig.connectionTimeoutMillis,
|
|
40
42
|
application_name: poolConfig.application_name,
|
|
41
43
|
ssl: poolConfig.ssl,
|
|
42
|
-
allowExitOnIdle
|
|
44
|
+
allowExitOnIdle
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
return poolConfig;
|
|
@@ -93,7 +93,13 @@ export class PgBase extends RelqBase {
|
|
|
93
93
|
async _query(sql) {
|
|
94
94
|
const executeQuery = async () => {
|
|
95
95
|
if (this.pool) {
|
|
96
|
-
|
|
96
|
+
const client = await this.pool.connect();
|
|
97
|
+
try {
|
|
98
|
+
return await client.query(sql);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
client.release();
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
104
|
else if (this.client) {
|
|
99
105
|
await this.ensureClientConnection();
|
|
@@ -6,6 +6,11 @@ export function registerGlobalCleanupHandlers() {
|
|
|
6
6
|
return;
|
|
7
7
|
if (typeof process === 'undefined' || !process.on)
|
|
8
8
|
return;
|
|
9
|
+
try {
|
|
10
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers')
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
catch { }
|
|
9
14
|
process.on('beforeExit', async () => {
|
|
10
15
|
if (activeInstances.size === 0)
|
|
11
16
|
return;
|
|
@@ -11,6 +11,8 @@ export function toPoolConfig(config) {
|
|
|
11
11
|
const port = config.aws?.port ?? config.port ?? 5432;
|
|
12
12
|
const user = config.aws?.user ?? config.user ?? (isAws ? 'admin' : undefined);
|
|
13
13
|
const ssl = isAws ? (config.aws.ssl ?? true) : config.ssl;
|
|
14
|
+
const isWorkers = typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers';
|
|
15
|
+
const allowExitOnIdle = !isWorkers;
|
|
14
16
|
const poolConfig = {
|
|
15
17
|
host,
|
|
16
18
|
port,
|
|
@@ -23,7 +25,7 @@ export function toPoolConfig(config) {
|
|
|
23
25
|
connectionTimeoutMillis: config.pool?.connectionTimeoutMillis ?? smartDefaults.connectionTimeoutMillis,
|
|
24
26
|
application_name: config.pool?.application_name,
|
|
25
27
|
ssl: config.pool?.ssl ?? ssl,
|
|
26
|
-
allowExitOnIdle
|
|
28
|
+
allowExitOnIdle
|
|
27
29
|
};
|
|
28
30
|
if (config.connectionString) {
|
|
29
31
|
return {
|
|
@@ -34,7 +36,7 @@ export function toPoolConfig(config) {
|
|
|
34
36
|
connectionTimeoutMillis: poolConfig.connectionTimeoutMillis,
|
|
35
37
|
application_name: poolConfig.application_name,
|
|
36
38
|
ssl: poolConfig.ssl,
|
|
37
|
-
allowExitOnIdle
|
|
39
|
+
allowExitOnIdle
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
return poolConfig;
|