Ticket: Timeouts - unit test fails

I have a similar issue as this original post except I my unit test fails . My poolsize ticket worked fine but the timeout ticket fails.

Expected: 2500
Received: undefined

My options are in order of your example. I am working in the mongoEvironment.js as the ticket indicates first until the test succeeds.

My Error

Try specifying the options in the URI rather than using parameters. See


and look for wtimeout.

I tried setting the wtimeoutMS option in the URI string (.env file ) but the test and Status page still failed.

Have you check the following:

I did indicate I have been working in the mongoEnvironment.js. I run the unit test “npm test -t timeouts” but I have also updated index.js with the same wtimeout: 2500, setting with the same results.

From https://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#mongoclient-connect-options, and if I understand correctly, it looks like the options should be written:

{
  db : { wtimeout : 2500 } ,
  server : {  poolSize : 50 }
}

May be it is a new syntax. May that what’s the error Top level use of w, wtimeout, j … is deprecated.

Give it a try. If it works we will both have learn.

1 Like

the server/replset/mongos/db options are deprecated, all their options are supported at the top level of the options object

[poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,keepAliveInitialDelay,connectTimeoutMS,family,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,writeConcern,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,checkServerIdentity,validateOptions,appname,auth,user,password,authMechanism,compression,fsync,readPreferenceTags,numberOfRetries,auto_reconnect,minSize,monitorCommands,retryWrites,retryReads,useNewUrlParser,useUnifiedTopology,serverSelectionTimeoutMS,useRecoveryToken,autoEncryption,driverInfo,tls,tlsInsecure,tlsinsecure,tlsAllowInvalidCertificates,tlsAllowInvalidHostnames,tlsCAFile,tlsCertificateFile,tlsCertificateKeyFile,tlsCertificateKeyFilePassword,minHeartbeatFrequencyMS,heartbeatFrequencyMS,directConnection,appName,maxPoolSize,minPoolSize,maxIdleTimeMS,waitQueueTimeoutMS]

the server/replset/mongos/db options are deprecated, all their options are supported at the top level of the options object

[poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,keepAliveInitialDelay,connectTimeoutMS,family,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,writeConcern,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,checkServerIdentity,validateOptions,appname,auth,user,password,authMechanism,compression,fsync,readPreferenceTags,numberOfRetries,auto_reconnect,minSize,monitorCommands,retryWrites,retryReads,useNewUrlParser,useUnifiedTopology,serverSelectionTimeoutMS,useRecoveryToken,autoEncryption,driverInfo,tls,tlsInsecure,tlsinsecure,tlsAllowInvalidCertificates,tlsAllowInvalidHostnames,tlsCAFile,tlsCertificateFile,tlsCertificateKeyFile,tlsCertificateKeyFilePassword,minHeartbeatFrequencyMS,heartbeatFrequencyMS,directConnection,appName,maxPoolSize,minPoolSize,maxIdleTimeMS,waitQueueTimeoutMS]

(node:15140) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15140) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.

i have the same problem with Eric Tomenga
but the db: {wtimeout : 2500} option works for me for the test and the api index.js

with the comon wtimeout: 2500 dont works
someone could explain this, to learn more
thanks

Thank you, i really needed this!!!

This documentation is what worked for me.

Note that writeConcern is what should be used as an object to replace the top level wtimeout, etc.

It is still interesting that I got multiple instances of this warning even though I used writeConcern:

Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.

It would be nice to understand why but I’ll assume the warnings are inconsequential at this time.

1 Like

Hi @Freddy_Mansilla, what’s the syntax for Ticket: Timeouts? I’m facing the same issue

hi, Wicleice_Fabio, change wtimeout to wtimeoutMS in timeouts.test.js, mongoEnvironment.js & in moviesDAO.js. You will pass the test.

I changed wtimeout to wtimeoutMS in all 3 files, but my tests are still failing

Determining test suites to run…Setup Mongo Connection
(node:9748) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

This is my code

process.env.MFLIX_DB_URI,
{poolSize: 50, tls: true},
{writeConcern: {
j: true, w:“majority”, wtimeoutMS:2500
}},
{ useNewUrlParser: true },
{ useUnifiedTopology: true }
)

can u plz help me out here. Btw I am using version 3.6.9 of mongodb