Application hangs on replicaset node falling down

Good afternoon.
There is a replica set of 2 nodes and an arbiter (all on different machines).
The node.js (express) app has a number of APIs for getting/updating etc. information both in the MongoDB database and in a database managed by another DBMS.
If I forcefully terminate one of the nodes, then Mongo Shell shows that the other node is running, it is primary, I can safely work with data in Mongo Shell. But when I try to call any API of the application, even one that does not work with MongoDB, the request seems to be sent into space: it is impossible to wait for a response, the request freezes. It feels like the application itself is hanging. But as soon as the node is restored, the application “wakes up” and returns a response.
What could be the reason?

mongoose 7.4.1
node 14.17.1
express 4.17.1

Tried the following connection strings:

mongoURI = “mongodb://[login]:[password]@[node1_ip]:27017,[node2_ip]:27017/[db_name]?authSource=admin&replicaSet=[rs_name]&readPreference=primaryPreferred&directConnection=false”

mongoURI = “mongodb://[login]:[password]@[node1_ip]:27017,[node2_ip]:27017/[db_name]?authSource=admin&readPreference=primaryPreferred&directConnection=false”

mongoURI = “mongodb://[login]:[password]@[node1_ip]:27017,[node2_ip]:27017/[db_name]?connectTimeoutMS=30000&authSource=admin&replicaSet=[rs_name]&readPreference=primaryPreferred&directConnection=false”

Database connection in my code:
await mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
maxPoolSize: 10,
serverSelectionTimeoutMS: 30000,
});

The only thing that helps in such a situation is to remove the inactive node from the replica set without touching the connection string to the database. But I need to achieve automatic recovery of the application.

It turned out to be a «connect-mongo» library.
Maybe, someone has encountered this?
I’ll dig further.