wingbot-mongodb 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"parent":null,"pid":69488,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1676391651316,"ppid":69487,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/6a7ed916-683a-43fd-8624-795a77e80a4a.json","externalId":"","uuid":"6a7ed916-683a-43fd-8624-795a77e80a4a","files":["/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
1
+ {"parent":null,"pid":81134,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1676533760202,"ppid":81133,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/98a862df-b2a1-4d14-9176-6b0bada108f7.json","externalId":"","uuid":"98a862df-b2a1-4d14-9176-6b0bada108f7","files":["/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
@@ -1 +1 @@
1
- {"processes":{"6a7ed916-683a-43fd-8624-795a77e80a4a":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["6a7ed916-683a-43fd-8624-795a77e80a4a"]},"externalIds":{}}
1
+ {"processes":{"98a862df-b2a1-4d14-9176-6b0bada108f7":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["98a862df-b2a1-4d14-9176-6b0bada108f7"]},"externalIds":{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -303,13 +303,14 @@ class NotificationsStorage {
303
303
 
304
304
  const findMissingIds = tasks
305
305
  .reduce((arr, {
306
- campaignId, senderId, pageId, sent
306
+ campaignId, senderId, pageId, sent, enqueue
307
307
  }, i) => {
308
308
  if (typeof res.upsertedIds[i] !== 'undefined') {
309
309
  return arr;
310
310
  }
311
311
  arr.push({
312
312
  i,
313
+ enqueue,
313
314
  filter: {
314
315
  campaignId, senderId, pageId, sent
315
316
  }
@@ -321,23 +322,31 @@ class NotificationsStorage {
321
322
 
322
323
  if (findMissingIds.length > 0) {
323
324
  await Promise.all(findMissingIds
324
- .map(({ filter, i }) => c.findOne(filter, {
325
+ .map(({ filter, i, enqueue }) => c.findOne(filter, {
325
326
  projection: {
326
327
  _id: 1, insEnqueue: 1, enqueue: 1, ups: 1
327
328
  }
328
329
  })
329
330
  .then((found) => {
330
- const id = typeof found._id === 'string'
331
- ? found._id
332
- : found._id.toHexString();
333
- missingIds.set(i, {
334
- id,
335
- insEnqueue: found.insEnqueue,
336
- enqueue: found.insEnqueue === found.enqueue
337
- && found.enqueue !== MAX_TS && found.ups !== 1
338
- ? found.enqueue + 1
339
- : found.enqueue
340
- });
331
+ if (!found) { // race condition occurred
332
+ missingIds.set(i, {
333
+ id: null,
334
+ insEnqueue: -1,
335
+ enqueue
336
+ });
337
+ } else {
338
+ const id = typeof found._id === 'string'
339
+ ? found._id
340
+ : found._id.toHexString();
341
+ missingIds.set(i, {
342
+ id,
343
+ insEnqueue: found.insEnqueue,
344
+ enqueue: found.insEnqueue === found.enqueue
345
+ && found.enqueue !== MAX_TS && found.ups !== 1
346
+ ? found.enqueue + 1
347
+ : found.enqueue
348
+ });
349
+ }
341
350
  })));
342
351
  }
343
352