Skip to content

Commit

Permalink
Merge pull request #777 from telefonicaid/task/release_transport_reso…
Browse files Browse the repository at this point in the history
…urces

release nodemailer transport resources
  • Loading branch information
fgalan authored May 31, 2024
2 parents faa2bfe + 0aaacb4 commit 50d03be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Fix: release transport resources of nodemailer after send email
- Upgrade express dep from 4.18.1 to 4.19.2 due to a vulnerability
- Upgrade nodemailer dep from 6.6.5 to 6.9.13 due to a vulnerability
7 changes: 6 additions & 1 deletion lib/models/emailAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ function buildMailOptions(action, event) {
}

function SendMail(action, event, callback) {
var transporter;
try {
// setup e-mail data with unicode symbols
var mailOptions = buildMailOptions(action, event),
transporterOptions = buildTransporterOptions(action, event),
opt2log,
smtpConfig,
transporter,
msgFromConfig;

if (transporterOptions.smtp) {
Expand Down Expand Up @@ -119,6 +119,11 @@ function SendMail(action, event, callback) {
// Not an HTTP request, so outgoingTransacion hasn't already counted and must be counted now
metrics.IncMetrics(event.service, event.subservice, metrics.outgoingTransactionsErrors);
return callback(ex);
} finally {
if (transporter) {
// release resources
transporter.close();
}
}
}

Expand Down

0 comments on commit 50d03be

Please sign in to comment.