fix: add missing returns in controller#402
Merged
aryandas2911 merged 3 commits intoMay 18, 2026
Merged
Conversation
Author
|
Hi @aryandas2911 , I have submitted this PR to address the runtime crash caused by missing return statements in the controller guard clauses, as outlined in the issue tracker. I also cleaned up a minor JSON argument syntax bug in The changes have been tested locally and ensure that the server no longer throws the "Cannot set headers after they are sent" error. Everything follows the project structure and is ready for your review. Could you please take a look when you have a moment? Thank you! 🙌 |
aryandas2911
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
This PR resolves a critical backend runtime crash where the server throws a
"Cannot set headers after they are sent"error. By adding missingreturnstatements to various controller guard clauses, we ensure that Express immediately exits the function after sending an error or validation response, preventing any subsequent code or duplicate responses from executing.Additionally, an Express syntax bug in the routine creation response payload was resolved to ensure proper frontend integration.
🔗 Related Issue
Closes #17
🛠 Changes Made
backend/controllers/taskController.jsreturnkeywords beforeres.status().json()calls across all guard clauses and validation checks increateTask,getTasks,updateTask, anddeleteTask.backend/controllers/routineController.jsreturnkeywords to guard clauses ingetRoutinesanddeleteRoutineto align with the acceptance criteria.createRoutinewherenewRoutinewas passed as a secondary argument to.json(). Rewrote it to properly bundlenewRoutineinside a single unified response object ({ success: true, message: "...", routine: newRoutine }).Codebase Audit
authController.jsto verify it already complies with the proper guard-clause exit patterns.📸 Screenshots (if applicable)
N/A (Backend logic and syntax architectural fixes only; no UI modifications).
✅ Checklist
🚀 Notes for Reviewers
createRoutine(routineController.js) to ensure it seamlessly aligns with what the frontend context expects.