-
Notifications
You must be signed in to change notification settings - Fork 6
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
Handle Mongoose Connection Failures Gracefully #24
Comments
okay im working on this issue for now and will update if any progress is made |
can i ask you where is the .env file from which mongouri is loading ( whenever i reload the application the mongouri variable becomes undefined) |
the .env file can not be included in the codebase for security reasons, users/contributors are required to register themselves on MongoDB Atlas, setup a new cluster and add their own connection uri in refer to README.md of the repo for more info |
okay made some final changes and some refactoring in the code and provided adequate responses for every situation (like if tickets array is empty or db connection was not successfull) here are some key changes:- change #1made db connection as a async function in a seperate js file called
so by awaiting connection to db stopped this potential timeout error change #2provided different responses for different situations as connection timeout , tickets are empty ,unable to connect to db or bad change #3chnaged front end accordingly displayed hmm.. Unable to load tickets. Please try again later. if unable to featch tickets or tickets are empty or in case of internal server error change #4reverted the changes you mentioned yesterday |
Hi @anshkarwasra, so far it seems good enough, please push the changes so that i can better understand the implementation and we can proceed further |
Description
Mongoose fails to connect to the database, the application does not currently handle the error, causing the app to crash unexpectedly. One common reason is that you're trying to access the database from an IP that isn't whitelisted. This leads to poor user experience on the frontend and unclear debugging information on the backend. To address this, we need to implement both frontend and backend improvements to ensure meaningful feedback, error handling and stability during database outages.
Steps to Reproduce
/api/Tickets
endpoint via the frontend.Proposed Solutions
1. Backend Enhancements
try-catch
block and handle connection errors.503 Service Unavailable
).2. Frontend Enhancements
Graceful Fallback UI:
Show a user-friendly message when the backend is unable to fetch data due to database connection issues.
The text was updated successfully, but these errors were encountered: