Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ensure transporter.verify returns a promise #1145

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/mailer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ export class MailerService {

private verifyTransporter(transporter: Transporter, name?: string): void {
const transporterName = name ? ` '${name}'` : '';
transporter.verify()
.then(() => this.mailerLogger.debug(`Transporter${transporterName} is ready`))
.catch((error) => this.mailerLogger.error(`Error occurred while verifying the transporter${transporterName}: ${error.message}`));

// wrap value in a promise to ensure then is always defined
new Promise(()=>transporter?.verify())
.then(() => this.mailerLogger.log(`Transporter${transporterName} is ready`))
.catch((error) => this.mailerLogger.log(`Error occurred while verifying the transporter${transporterName}}: ${error.message}`));
Comment on lines +111 to +112

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the log level (debug/error -> log)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, the point here is to just wrap it in a promise and keep the default behavior

}

public async verifyAllTransporters() {
Expand Down