Jaishree2310/GlassyUI-Components

BUG:There is a critical async error-handling issue in the server-side controllers that can crash the Node.js process in production.

Open

#608 opened on May 25, 2026

View on GitHub
 (6 comments) (0 reactions) (0 assignees)TypeScript (217 forks)auto 404
good first issuegssoc'26gssoc:approvedlevel:beginnertype:bug

Repository metrics

Stars
 (114 stars)
PR merge metrics
 (PR metrics pending)

Description

Preliminary Check

  • I have searched the existing issues
  • This issue is reproducible

Bug Summary

There is a critical async error-handling issue in the server-side controllers where asynchronous email operations are triggered without being awaited or properly handled.

Affected controllers:

  • server/controllers/contactController.js
  • server/controllers/newsletterController.js

Current logic:

sendMailToAdmin(newContact);

starts an async mail operation but does not:

  • await the promise
  • attach .catch()
  • handle failures safely

If the SMTP server fails, credentials are invalid, or required environment variables are missing, the promise rejection becomes unhandled.

In Node.js 15+, unhandled promise rejections may terminate the entire server process. Even in older versions, this can cause unstable logging, memory leaks, and unpredictable backend behavior.

Expected: Async email operations should be properly awaited and wrapped in error handling.

Actual: Unhandled promise rejections can occur and potentially crash the backend process.

Steps to Reproduce

  1. Configure invalid or missing email environment variables:
EMAIL_ID=
PASS_KEY=
  1. Start the backend server

  2. Trigger the contact or newsletter endpoint

  3. Cause the mail service to fail (invalid SMTP credentials, unreachable mail server, etc.)

  4. Observe server logs for unhandled promise rejection warnings/errors

Example problematic flow:

sendMailToAdmin(newContact); // not awaited
  1. Depending on the Node.js version/configuration:
  • backend logs unhandled rejection warnings
  • runtime becomes unstable
  • process may terminate entirely

Expected Behavior

Async mail operations should:

  • be properly awaited
  • or explicitly handled with .catch()

Unexpected email failures should:

  • return controlled API responses
  • not create unhandled promise rejections
  • not risk crashing the Node.js process

Recommended behavior:

await sendMailToAdmin(newContact);

inside a proper try/catch block.


Screenshots / Logs

Example runtime warning:

UnhandledPromiseRejectionWarning: Error: Invalid login

Possible Node.js termination behavior:

Unhandled promise rejection. The process will exit.

Additional Information

  • Backend issue
  • Critical production stability risk
  • Affects async email handling
  • Reproducible with invalid SMTP configuration

Checklist

  • I have searched the existing issues
  • This issue is reproducible
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
  • I'm a GSSOC'24 contributor
  • I can provide more details if needed

Screenshots/Logs

No response

Additional Information

  • I agree to follow this project's Code of Conduct
  • I'm a GSSOC'24 contributor
  • I want to work on this issue
  • I can provide more details if needed

Contributor guide