File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -179,10 +179,11 @@ program
179179 console . log ( `Monitoring user: ${ opts . monitoringUser } ` ) ;
180180 console . log ( `Optional permissions: ${ includeOptionalPermissions ? "enabled" : "skipped" } ` ) ;
181181
182+ // Use native pg client instead of requiring psql to be installed
183+ const { Client } = require ( "pg" ) ;
184+ const client = new Client ( adminConn . clientConfig ) ;
185+
182186 try {
183- // Use native pg client instead of requiring psql to be installed
184- const { Client } = require ( "pg" ) ;
185- const client = new Client ( adminConn . clientConfig ) ;
186187 await client . connect ( ) ;
187188
188189 const roleRes = await client . query ( "select 1 from pg_catalog.pg_roles where rolname = $1" , [
@@ -205,7 +206,6 @@ program
205206 } ) ;
206207
207208 const { applied, skippedOptional } = await applyInitPlan ( { client, plan } ) ;
208- await client . end ( ) ;
209209
210210 console . log ( "✓ init completed" ) ;
211211 if ( skippedOptional . length > 0 ) {
@@ -226,6 +226,12 @@ program
226226 }
227227 }
228228 process . exitCode = 1 ;
229+ } finally {
230+ try {
231+ await client . end ( ) ;
232+ } catch {
233+ // ignore
234+ }
229235 }
230236 } ) ;
231237
You can’t perform that action at this time.
0 commit comments