Skip to content

Commit 618ddf7

Browse files
committed
fix(cleanup): minor memory cleanup during long running process when waiting for check to be sent to github
1 parent 0b08a6c commit 618ddf7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ module.exports = (app) => {
3737
pull_number: context.payload.issue.number
3838
}));
3939
pr = response.data;
40+
// cleanup
41+
response = null;
4042
} catch (err) {
4143
context.log.error(`Error looking up PR, skipping. Error (${err.status}): ${err.message}`);
4244
}
@@ -76,6 +78,8 @@ module.exports = (app) => {
7678
comments.data = comments.data.filter(comment => {
7779
return ! bots.includes(comment.user.login);
7880
});
81+
// cleanup
82+
bots = null;
7983

8084
} catch (err) {
8185
if (err.status === 403) { // if we don't have access to the repo, skip entirely
@@ -97,6 +101,8 @@ module.exports = (app) => {
97101
if (reviewComments.data.length) {
98102
comments.data = comments.data.concat(reviewComments.data);
99103
}
104+
// cleanup
105+
reviewComments = null;
100106
} catch (err) {
101107
log(pr, `Error looking up review comments, skipping. Error (${err.status}): ${err.message}`, 'error');
102108
}
@@ -112,6 +118,8 @@ module.exports = (app) => {
112118
if (reviewDiffComments.data.length) {
113119
comments.data = comments.data.concat(reviewDiffComments.data);
114120
}
121+
// cleanup
122+
reviewDiffComments = null;
115123
} catch (err) {
116124
log(pr, `Error looking up review diff comments, skipping. Error (${err.status}): ${err.message}`, 'error');
117125
}
@@ -183,6 +191,13 @@ ${outstandingTasks.optionalTasks.map(task => `| ${task.task} | ${task.status} |`
183191

184192
log(pr, 'Complete and sending back to GitHub');
185193

194+
// cleanup
195+
prBody = null;
196+
outstandingTasks = null;
197+
comments = null;
198+
tasksTable = null;
199+
optionalText = null;
200+
186201
// send check back to GitHub
187202
try {
188203
const response = await context.octokit.checks.create(context.repo(check));

0 commit comments

Comments
 (0)