RocketChat/Rocket.Chat · error
Fetch error
Error message
Fetch error
What it means
The IMAP interceptor's batch fetch (imap.fetch over a set of message ids, requesting HEADER/TEXT bodies and structure) emitted an 'error' event. Unlike the per-message flag warning, this handler rejects the enclosing promise, so the whole poll cycle for those emailIds fails and the caller of getEmails receives the rejection. Typical causes are a dropped connection mid-fetch, sequence numbers invalidated by concurrent mailbox changes, or server-side timeouts.
Source
Thrown at apps/meteor/server/email/IMAPInterceptor.ts:202
simpleParser(new Readable().wrap(stream), (_err, email) => {
if (this.options.rejectBeforeTS && email.date && email.date < this.options.rejectBeforeTS) {
logger.error({ msg: 'Rejecting email on inbox', user: this.config.user, subject: email.subject });
return;
}
this.emit('email', email);
if (this.options.deleteAfterRead) {
this.imap.seq.addFlags(email, 'Deleted', (err) => {
if (err) {
logger.warn({ msg: 'Mark deleted error', err });
}
});
}
});
};
msg.once('body', bodycb);
};
const errorcb = (err: Error): void => {
logger.warn({ msg: 'Fetch error', err });
reject(err);
};
const endcb = (): void => {
resolve(out);
};
const fetch = this.imap.fetch(emailIds, {
bodies: ['HEADER', 'TEXT', ''],
struct: true,
markSeen: this.options.markSeen,
});
fetch.on('message', messagecb);
fetch.on('error', errorcb);
fetch.on('end', endcb);
});
}
// Fetch all UNSEEN messages and pass them for further processingView on GitHub (pinned to b2c16d5842)
Solutions
- Read the err text for 'BYE', 'timeout', or 'Connection error' to classify it
- Reduce fetch batch size and poll frequency
- Ensure only one consumer processes the mailbox
- Make the polling loop catch the rejection, reconnect, and retry with backoff instead of dying
Defensive patterns
Strategy: retry
Try / catch
try {
const ids = await interceptor.getEmails();
} catch (error) {
logger.warn({ msg: 'IMAP fetch failed, reconnecting', err: error });
await interceptor.reconnect();
// retry the batch once after reconnect; then back off
} Prevention
- Fetch in small batches so a mid-fetch disconnect loses little work
- Ensure a single consumer per mailbox to avoid sequence-number churn from concurrent expunges
- Wrap the polling loop with reconnect + backoff instead of letting one rejection kill the channel
When it happens
Trigger: Connection reset while streaming message bodies; another client expunging messages so sequence numbers shift under the running fetch; fetching a very large backlog exceeding the server's command timeout; server sending BYE due to inactivity/throttling.
Common situations: Inbound-email channel against shared IMAP hosts with aggressive timeouts; two consumers (Rocket.Chat plus a mail client) working the same mailbox; first connect after downtime fetching a huge backlog.
Related errors
- Mark deleted error
- error-invalid-email-address
- error-email-send-failed
- App package download failed
- App metadata download failed
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/813b85a877814bbb.
Report an issue: GitHub.