-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: allow client connect after close #2615
fix: allow client connect after close #2615
Conversation
@@ -618,6 +617,7 @@ function processError(changeStream: ChangeStream, error: AnyError, callback?: Ca | |||
// close internal cursor, ignore errors | |||
cursor.close(); | |||
|
|||
const topology = getTopology(changeStream.parent); | |||
waitForTopologyConnected(topology, { readPreference: cursor.readPreference }, err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the topology too early in this function causes failing tests when processError
is called after client close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
ceb9476
to
4e52381
Compare
This reinstates the work from #2581 now that NODE-2850 is complete.
During
close
of aMongoClient
, we remove thetopology
. Then, when a client is reconnected, a new topology is created and added to the client. First, this means references toDb
s andCollection
s can be re-used after the reconnect, since they will pull the new topology from the client. Also, when an operation requiring a topology is performed on a closed client, an error is thrown.After this, the work of figuring out how to re-connect a topology is one of the last steps towards having a single, immutable topology associated with a
MongoClient
. As in #2581, I skipped this work for now, since the refactor required to re-connect topologies may be too much work for this ticket.NODE-2544