drudge / mongoose-timestamp

Adds createdAt and updatedAt date attributes that get auto-assigned to the most recent create/update timestamp
Other
308 stars 64 forks source link

Timestamp Auto closed the TCP cause MongoNetworkError #49

Open kayac-chang opened 5 years ago

kayac-chang commented 5 years ago

I Worked with

Do you want to request a feature or report a bug? I want to report a bug.

What is the current behavior? When I working with a long process task like transfer data from MySQL to Mongo Atlas. I try so many time but finally I got this:

(node:74121) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 2 to cluster0-shard-00-01-ug0nb.gcp.mongodb.net:27017 closed
    at TLSSocket.<anonymous> (/Users/kayac/Projects/Work/Backend_Server/node_modules/mongodb-core/lib/connection/connection.js:352:9)
    at Object.onceWrapper (events.js:288:20)
    at TLSSocket.emit (events.js:200:13)
    at net.js:586:12
    at TCP.done (_tls_wrap.js:479:7)

And My config like this:

    const db = await mongoose.connect(path, {
        useNewUrlParser: true,
        socketTimeoutMS: 600 * 1000,
        connectTimeoutMS: 600 * 1000,
        autoReconnect: true,
        keepAlive: true,
        reconnectTries: 30,
        poolSize: 20,
    });

socketTimeoutMSand connectTimeoutMS both doesn't help.

But I remove the

const timestamps = require('mongoose-timestamp');
Schema.plugin(timestamps);

And My task success.

Did mongoose timestamp auto close the TCP connection when process too long?