File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ export class PgPoolCacheManager {
105105 this . closed = true ;
106106 this . clear ( ) ;
107107 await this . waitForDisposals ( ) ;
108+ // Re-open the cache so it can accept new entries if the process
109+ // survives the shutdown signal (e.g. during provisioning or restart).
110+ this . closed = false ;
108111 }
109112
110113 async waitForDisposals ( ) : Promise < void > {
@@ -141,9 +144,14 @@ export const close = async (verbose = false): Promise<void> => {
141144 if ( closePromise . promise ) return closePromise . promise ;
142145
143146 closePromise . promise = ( async ( ) => {
144- if ( verbose ) log . info ( 'Closing pg cache...' ) ;
145- await pgCache . close ( ) ;
146- if ( verbose ) log . success ( 'PG cache disposed.' ) ;
147+ try {
148+ if ( verbose ) log . info ( 'Closing pg cache...' ) ;
149+ await pgCache . close ( ) ;
150+ if ( verbose ) log . success ( 'PG cache disposed.' ) ;
151+ } finally {
152+ // Reset so close() can be called again if the process survives.
153+ closePromise . promise = null ;
154+ }
147155 } ) ( ) ;
148156
149157 return closePromise . promise ;
@@ -158,4 +166,4 @@ SYS_EVENTS.forEach(event => {
158166
159167export const teardownPgPools = async ( verbose = false ) : Promise < void > => {
160168 return close ( verbose ) ;
161- } ;
169+ } ;
You can’t perform that action at this time.
0 commit comments