test: log e11000 errors

isekai-main
Barış Soner Uşaklı 2 years ago
parent 052f1f2232
commit 934df69e9d

@ -26,7 +26,8 @@ module.exports = function (module) {
await module.client.collection('objects').updateOne({ _key: key }, { $set: writeData }, { upsert: true });
}
} catch (err) {
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, key, data);
return await module.setObject(key, data);
}
throw err;
@ -61,7 +62,8 @@ module.exports = function (module) {
await bulk.execute();
}
} catch (err) {
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, data);
return await module.setObjectBulk(data);
}
throw err;
@ -256,7 +258,8 @@ module.exports = function (module) {
// https://jira.mongodb.org/browse/SERVER-14322
// https://docs.mongodb.org/manual/reference/command/findAndModify/#upsert-and-unique-index
console.log('test', err.message);
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, key, field, value);
return await module.incrObjectFieldBy(key, field, value);
}
throw err;

@ -51,7 +51,8 @@ module.exports = function (module) {
try {
await bulk.execute();
} catch (err) {
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, keys, value);
return await module.setsAdd(keys, value);
}
throw err;

@ -443,7 +443,8 @@ module.exports = function (module) {
// https://github.com/NodeBB/NodeBB/issues/4467
// https://jira.mongodb.org/browse/SERVER-14322
// https://docs.mongodb.org/manual/reference/command/findAndModify/#upsert-and-unique-index
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, key, increment, value);
return await module.sortedSetIncrBy(key, increment, value);
}
throw err;

@ -19,7 +19,8 @@ module.exports = function (module) {
try {
await module.client.collection('objects').updateOne({ _key: key, value: value }, { $set: { score: parseFloat(score) } }, { upsert: true });
} catch (err) {
if (err && err.message.startsWith('E11000 duplicate key error')) {
if (err && err.message.includes('E11000 duplicate key error')) {
console.log(new Error('e11000').stack, key, score, value);
return await module.sortedSetAdd(key, score, value);
}
throw err;

Loading…
Cancel
Save