Skip to content

fix bad connection try/catch logic - #367

Open
hamishwillee wants to merge 1 commit into
mainfrom
fix_bad_connection_logic
Open

fix bad connection try/catch logic#367
hamishwillee wants to merge 1 commit into
mainfrom
fix_bad_connection_logic

Conversation

@hamishwillee

@hamishwillee hamishwillee commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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

@hamishwillee
hamishwillee requested review from a team as code owners September 4, 2026 02:17
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
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants