Skip to content

Commit fec7acb

Browse files
authored
Use client instead of size 1 pool (#7182)
1 parent feca439 commit fec7acb

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/gcp/cloudsql/connect.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function execute(
3232
);
3333
}
3434
let connector: Connector;
35-
let pool: pg.Pool;
35+
let client: pg.Client;
3636
switch (user.type) {
3737
case "CLOUD_IAM_USER": {
3838
connector = new Connector({
@@ -43,11 +43,10 @@ export async function execute(
4343
ipType: IpAddressTypes.PUBLIC,
4444
authType: AuthTypes.IAM,
4545
});
46-
pool = new pg.Pool({
46+
client = new pg.Client({
4747
...clientOpts,
4848
user: opts.username,
4949
database: opts.databaseId,
50-
max: 1,
5150
});
5251
break;
5352
}
@@ -61,11 +60,10 @@ export async function execute(
6160
ipType: IpAddressTypes.PUBLIC,
6261
authType: AuthTypes.IAM,
6362
});
64-
pool = new pg.Pool({
63+
client = new pg.Client({
6564
...clientOpts,
6665
user: opts.username,
6766
database: opts.databaseId,
68-
max: 1,
6967
});
7068
break;
7169
}
@@ -81,12 +79,11 @@ export async function execute(
8179
instanceConnectionName: connectionName,
8280
ipType: IpAddressTypes.PUBLIC,
8381
});
84-
pool = new pg.Pool({
82+
client = new pg.Client({
8583
...clientOpts,
8684
user: opts.username,
8785
password: opts.password,
8886
database: opts.databaseId,
89-
max: 1,
9087
});
9188
break;
9289
}
@@ -96,13 +93,13 @@ export async function execute(
9693
for (const s of sqlStatements) {
9794
logFn(`Executing: '${s}'`);
9895
try {
99-
await pool.query(s);
96+
await client.query(s);
10097
} catch (err) {
10198
throw new FirebaseError(`Error executing ${err}`);
10299
}
103100
}
104101

105-
await pool.end();
102+
await client.end();
106103
connector.close();
107104
}
108105

0 commit comments

Comments
 (0)