Skip to content

Commit 353ff7a

Browse files
committed
destroy agents
1 parent bee9e95 commit 353ff7a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

packages/@aws-cdk/toolkit-lib/lib/api/aws-auth/awscli-compatible.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,6 @@ export interface CredentialChainOptions {
270270
}
271271

272272
export function sdkRequestHandler(agent?: Agent): RequestHandlerSettings {
273-
process.on('beforeExit', () => {
274-
// eslint-disable-next-line no-console
275-
console.log('Cleaning up SDK resources before exit...');
276-
agent?.destroy();
277-
});
278-
process.on('SIGINT', () => {
279-
agent?.destroy(); process.exit();
280-
});
281-
282273
return {
283274
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT,
284275
requestTimeout: DEFAULT_TIMEOUT,

packages/aws-cdk/lib/cli/cli.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
100100
caBundlePath: configuration.settings.get(['caBundlePath']),
101101
});
102102

103+
function destroyAgent() {
104+
try {
105+
proxyAgent.destroy();
106+
} catch (_) {
107+
}
108+
}
109+
110+
process.on('beforeExit', () => {
111+
// eslint-disable-next-line no-console
112+
console.log('Cleaning up SDK resources before exit...');
113+
destroyAgent();
114+
});
115+
process.on('SIGINT', () => {
116+
destroyAgent(); process.exit();
117+
});
118+
103119
if (argv['telemetry-file'] && !configuration.settings.get(['unstable']).includes('telemetry')) {
104120
throw new ToolkitError('Unstable feature use: \'telemetry-file\' is unstable. It must be opted in via \'--unstable\', e.g. \'cdk deploy --unstable=telemetry --telemetry-file=my/file/path\'');
105121
}

0 commit comments

Comments
 (0)