Skip to content

Commit

Permalink
fix(fetch): use batches when fetching message entries for indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Mar 5, 2024
1 parent 33ef225 commit 1e83e64
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 121 deletions.
21 changes: 20 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,26 @@ class Connection {
this.logger.info({ msg: 'Connection closed', type: 'imapClient', account: this.account });

try {
for (let mailbox of this.mailboxes) {
for (let [, mailbox] of this.mailboxes) {
if (mailbox.syncing) {
try {
// set failure flag
await this.redis.hSetNew(
this.getAccountKey(),
'syncError',
JSON.stringify({
path: mailbox.path,
time: new Date().toISOString(),
error: {
error: 'Connection closed unexpectedly'
}
})
);
} catch (err) {
// ignore
}
}

if (mailbox.selected) {
// should be at most one though
await mailbox.onClose();
Expand Down
5 changes: 5 additions & 0 deletions lib/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ module.exports = {

MIME_BOUNDARY_PREFIX: '----=_Part',

FETCH_RETRY_INTERVAL: 1000,
FETCH_RETRY_EXPONENTIAL: 2,
FETCH_RETRY_MAX: 60 * 1000,
MAX_FETCH_RANGE: 1000,

generateWebhookTable() {
let entries = [];

Expand Down
Loading

0 comments on commit 1e83e64

Please sign in to comment.