-
Notifications
You must be signed in to change notification settings - Fork 239
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead. #616
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
Comments
I'm getting the same error too, I use: loopback 3.27.0, I didn't do any version updates, everything worked perfectly and now this message is floating around. On my local computer this message does not appear, only in Amazon's ElastichBean. |
I believe this is just staying that use of For example. This let mongodbClient = new MongoClient({
useUnifiedTopology: true,
useNewUrlParser: true,
connectTimeoutMS: 10000,
poolSize: 10,
j: true
}); Should be update to this: let mongodbClient = new MongoClient({
useUnifiedTopology: true,
useNewUrlParser: true,
connectTimeoutMS: 10000,
poolSize: 10,
writeConcern: {
j: true
}
}); See the following MongoDB Node.js documentation on WriteConcern |
Nope, doesn't work i modify my datasource to this: import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
const config = {
name: 'mongodb',
connector: 'mongodb',
host: '0.0.0.0',
port: 27017,
user: 'user',
password: 'XXXXX',
database: 'db_name',
useNewUrlParser: true,
useUnifiedTopology: true,
writeConcern: {
j: true,
},
};
// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The `stop()` method is inherited from `juggler.DataSource`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class MongodbDataSource
extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'mongodb';
static readonly defaultConfig = config;
constructor(
@inject('datasources.config.mongodb', {optional: true})
dsConfig: object = config,
) {
super(dsConfig);
}
} I am still getting the same warning message "Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead." |
same here on my local machine |
Same problem. I removed option { w: 0 } from insertOne operation and - no warning! native mongodb node.js driver v3.6.4 |
The error is there from the beginning
Then after each request GET, POST, PUT, PATCH is repeated, I change the configuration as you mentioned but nothing happens |
for me error on start is this:
Probably something related to connector or juggler |
The deprecation warning is coming from the MongoDB driver. Was introduced in v3.6.4. |
It is not an error it is a warning from node-mongodb-native. As @arbourd says is introduced in v3.6.4(https://github.com/mongodb/node-mongodb-native/blob/v3.6.4/lib/write_concern.js)
If not use object writeConcern return:
and loopback-connector-mongodb not implemented is option in validOptionNames https://github.com/strongloop/loopback-connector-mongodb/blob/master/lib/mongodb.js:
|
@valdepeace I understand the warning is coming from the MongoDB Node.js driver, but updating my
Still get's me |
I've created an official bug report on the Jira for the Node.js driver at https://jira.mongodb.org/browse/NODE-3114 if anybody wants to follow along or chime in. |
its definitely the db.collection call if you change MongoDB.prototype.collection = function(modelName) {
if (!this.db) {
throw new Error(g.f('{{MongoDB}} connection is not established'));
}
const collectionName = this.collectionName(modelName);
return this.db.collection(collectionName);
}; to include the writeConcern object MongoDB.prototype.collection = function(modelName) {
if (!this.db) {
throw new Error(g.f('{{MongoDB}} connection is not established'));
}
const collectionName = this.collectionName(modelName);
return this.db.collection(collectionName, { writeConcern: { w: null } });
}; it stops complaining would have todo the same with the ping function as it calls db.collection directly |
As a temporary hack before we get a proper fix, I have added the prototype function from previous comment to my server/datasources.local.js It gets rid of most of the warnings. let mongoConnector = require('loopback-connector-mongodb');
let MongoDB = mongoConnector.MongoDB;
MongoDB.prototype.collection = function(model) {
if (!this.db) {
throw new Error(g.f('{{MongoDB}} connection is not established'));
}
var collectionName = this.collectionName(model);
return this.db.collection(collectionName, { writeConcern: { w: null } });
}; |
I just submit a PR to node-mongodb-native driver to fix the merging of writeConcern mongodb/node-mongodb-native#2744 which stop warning outputs. An other PR is related to our topic and will remove the warnings mongodb/node-mongodb-native/pull/2743 |
@wolrajhti , curious I see the PRs merged, but I'm still seeing the issue on my end, did mongodb 3.6.4 get updated or will a new version needs to be released? |
@RAI-shyam A fix has been done on the branch 3.6 of the mongodb driver, it will be available when they will released 3.6.5 (or 3.7). hopefully very soon 🤞 |
Updating the version to
|
Hey @ashwinsoni. My package.json shows i'm already using "v5.5.0" but i still get this warning. |
Updating to version 6.0.0 resolves this for me.
|
Thanks @akkapur! Upgrading to version 6.0.0 resolves it for me as as well. |
@Adimvicky Sorry about that, seems like the modules were not cleaned and rebuild after updating to 5.5.0 on your machine. |
try add this one |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Since yesterday without any change on package.json or code change i am getting an error at console per request.
Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
Any ideas?
I am using latest mongoDB version (4.4.3) container image
mongo datasource
Please advice!
The text was updated successfully, but these errors were encountered: