Repository navigation
Replace process.exit with graceful connection close in test cleanup - #222
Open
BismaKodes wants to merge 1 commit into
Open
BismaKodes wants to merge 1 commit into
BismaKodes wants to merge 1 commit into
Conversation
Open
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.
Fixes #149
Replaces the forced
process.exit(0)in the test cleanup with a gracefulshutdown of the mongoose connection instead.
connection.close()to properly close the database connection.disconnectedevent listener before closing. The app is setup to auto-reconnect whenever the connection disconnects
(
connection.on('disconnected', connect)in server.js). Without removingthis listener first, calling
.close()would immediately trigger a newreconnect, causing the process to hang indefinitely instead of exiting
cleanly.
This avoids force-killing the process and lets Node exit naturally once
the connection is properly closed.
Note: I noticed that running
npm testcurrently reports# tests 0regardless of the cleanup method used — this appears to be a separate,
pre-existing issue (possibly related to session store / connection timing
on the "Home page" test) rather than something caused by this change.
Happy to investigate further in a separate issue/PR if that would be useful.