Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit de16bf4

Browse files
authored
Add explicit client closure to V1 Lambdas (#840)
* Update jobs.ts * [fix] Make linter happy * Deploy to preprd * Await client.close invocation * Consolidate logic
1 parent d2425b5 commit de16bf4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/deploy-stg-ecs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
branches:
44
- "master"
55
- "integration"
6+
- "close-lambda-mdb-clients"
67
concurrency:
78
group: environment-stg-${{ github.ref }}
89
cancel-in-progress: true

api/controllers/v1/jobs.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,26 @@ export const TriggerLocalBuild = async (event: any = {}, context: any = {}): Pro
1919
const consoleLogger = new ConsoleLogger();
2020
const sqs = new SQSConnector(consoleLogger, c);
2121
const body = JSON.parse(event.body);
22+
let resp = {};
2223
try {
2324
consoleLogger.info(body.jobId, 'enqueuing Job');
2425
await sqs.sendMessage(new JobQueueMessage(body.jobId, JobStatus.inQueue), c.get('jobUpdatesQueueUrl'), 0);
2526
consoleLogger.info(body.jobId, 'Job Queued Job');
26-
return {
27+
resp = {
2728
statusCode: 202,
2829
headers: { 'Content-Type': 'text/plain' },
2930
body: body.jobId,
3031
};
3132
} catch (err) {
3233
consoleLogger.error('TriggerLocalBuild', err);
33-
return {
34+
resp = {
3435
statusCode: 500,
3536
headers: { 'Content-Type': 'text/plain' },
3637
body: err,
3738
};
39+
} finally {
40+
await client.close();
41+
return resp;
3842
}
3943
};
4044

@@ -108,6 +112,8 @@ export const FailStuckJobs = async () => {
108112
await jobRepository.failStuckJobs(hours);
109113
} catch (err) {
110114
consoleLogger.error('FailStuckJobs', err);
115+
} finally {
116+
await client.close();
111117
}
112118
};
113119

@@ -126,6 +132,8 @@ async function saveTaskId(jobId: string, taskExecutionRes: any, consoleLogger: C
126132
await jobRepository.addTaskIdToJob(jobId, taskId);
127133
} catch (err) {
128134
consoleLogger.error('saveTaskId', err);
135+
} finally {
136+
await client.close();
129137
}
130138
}
131139

@@ -181,6 +189,7 @@ async function NotifyBuildSummary(jobId: string): Promise<any> {
181189
),
182190
entitlement['slack_user_id']
183191
);
192+
await client.close();
184193
return {
185194
statusCode: 200,
186195
};
@@ -284,6 +293,7 @@ async function NotifyBuildProgress(jobId: string): Promise<any> {
284293
),
285294
entitlement['slack_user_id']
286295
);
296+
await client.close();
287297
return {
288298
statusCode: 200,
289299
};
@@ -333,4 +343,5 @@ async function SubmitArchiveJob(jobId: string) {
333343
repo.prefix[environment]
334344
);
335345
consoleLogger.info('submit archive job', JSON.stringify({ jobId: jobId, batchJobId: response.jobId }));
346+
await client.close();
336347
}

0 commit comments

Comments
 (0)