Facebook Pixel

Should I await email sending in my route handlers?

No. Don't block the HTTP response on email sending. Use fire and forget (sendEmail().catch(err => console.error(err))) so the user gets their response immediately. The email sends in the background. For critical emails, use a queue (Bull, SQS).

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Transactional Emails in Node.js Password Reset, Welcome, and Notification Emails

After creating the user, call sendEmail with the welcome template. Don't await the email use fire and forget (.catch for error logging) so the user gets their response immediately. The email sends in the background.

Generate a random token (crypto.randomBytes), hash it, save to user with 1-hour expiry. Send an email with a reset link containing the raw token. On reset, verify the hashed token and expiry, update the password, and clear the token.

In the Socket.io message:send handler, check if the receiver is online. If not, send an email notification with the sender's name, a snippet of the message, and a link to the chat. This keeps offline users informed without SMS/push notifications.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0