fix bad connection try/catch logic - #367
Open
hamishwillee wants to merge 1 commit into
Open
Conversation
hamishwillee
added a commit
to hamishwillee/content
that referenced
this pull request
Sep 4, 2026
The bin/www generated by express-generator starts the HTTP server unconditionally, so simply fixing the connectMongoose() try/catch logic wasn't enough: readers following the tutorial would still end up with a server that starts regardless of whether the database connected. Move server creation into a startServer() function that only runs once connectMongoose() resolves, matching the upstream fix in mdn/express-locallibrary-tutorial#367. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018BoWRns9KXjAdyMZMeQ4g2
dipikabh
approved these changes
Sep 4, 2026
Josh-Cena
added a commit
to mdn/content
that referenced
this pull request
Sep 4, 2026
* Fix connection logic that didn't catch failed connections * Also gate HTTP server start on successful MongoDB connection The bin/www generated by express-generator starts the HTTP server unconditionally, so simply fixing the connectMongoose() try/catch logic wasn't enough: readers following the tutorial would still end up with a server that starts regardless of whether the database connected. Move server creation into a startServer() function that only runs once connectMongoose() resolves, matching the upstream fix in mdn/express-locallibrary-tutorial#367. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018BoWRns9KXjAdyMZMeQ4g2 --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
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.
The connection logic was never going to work because it was try...catching in the wrong place.
In addition, server starting was not gated on connecting. This fixes it up. Tested in WSL.
Corresponding docs fix mdn/content#45492
Fell out of mdn/content#45473