Skip to content

Commit 176192c

Browse files
committed
[push] Fixing unsuccessfull message compilation for highly-concurrent cases
1 parent e610d7c commit 176192c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

plugins/push/api/jobs/process.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,18 @@ class ProcessJob extends J.IPCJob {
361361
}
362362

363363
// load next batch
364-
let msgs = await this.loader.load(this._id, date, BATCH),
365-
ids = msgs.map(m => m.n.toString());
366-
367-
// reload notes for msgs
368-
ids = ids.filter((id, i) => ids.indexOf(id) === i);
369-
notes = await this.loader.notes(ids);
364+
let msgs = await this.loader.load(this._id, date, BATCH);
370365

371366
// no messages left, break from the loop
372367
if (!msgs.length) {
373368
break;
374369
}
375370

371+
// reload notes for msgs
372+
let ids = msgs.map(m => m.n.toString());
373+
ids = ids.filter((id, i) => ids.indexOf(id) === i);
374+
notes = await this.loader.notes(ids);
375+
376376
// mark messages as being sent
377377
await Promise.all(Object.values(notes).map(json => this.loader.updateNote(json._id, {$addToSet: {jobs: this._id}, $bit: {'result.status': {or: N.Status.Sending}}})));
378378
Object.values(notes).map(n => n._id.toString()).forEach(id => sending.add(id));

0 commit comments

Comments
 (0)