File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/@aws-cdk/toolkit-lib/lib/api/aws-auth Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -270,10 +270,28 @@ export interface CredentialChainOptions {
270270}
271271
272272export function sdkRequestHandler ( agent ?: Agent ) : RequestHandlerSettings {
273- return {
273+ const destroyAgents = ( config : RequestHandlerSettings ) => {
274+ try {
275+ config . httpAgent ?. destroy ( ) ;
276+ } catch ( _ ) {
277+ }
278+ try {
279+ config . httpsAgent ?. destroy ( ) ;
280+ } catch ( _ ) {
281+ }
282+ } ;
283+
284+ const result = {
274285 connectionTimeout : DEFAULT_CONNECTION_TIMEOUT ,
275286 requestTimeout : DEFAULT_TIMEOUT ,
276287 httpsAgent : agent ,
277288 httpAgent : agent ,
278289 } ;
290+
291+ process . on ( 'beforeExit' , ( ) => destroyAgents ( result ) ) ;
292+ process . on ( 'SIGINT' , ( ) => {
293+ destroyAgents ( result ) ; process . exit ( ) ;
294+ } ) ;
295+
296+ return result ;
279297}
You can’t perform that action at this time.
0 commit comments