DIYgod/RSSHub · error · Error
${(error as { responseText: string }).responseText}
Error message
${(error as { responseText: string }).responseText} What it means
Thrown by the Email IMAP handler (lib/routes/mail/imap.ts:58) when `client.connect()` from `imapflow` rejects. The caught error is cast to `{ responseText: string }` and its `responseText` becomes the message; if the underlying error has no such property the message is literally `"undefined"`, obscuring the real cause.
Source
Thrown at lib/routes/mail/imap.ts:58
port: Number.parseInt(String(mailConfig.port)),
secure: true,
auth: {
user: mailConfig.username,
pass: mailConfig.password,
},
proxy: config.proxyUri, // Note: socks5h is not supported
logger: {
debug: (log) => logger.debug(log.msg),
info: (log) => logger.info(log.msg),
warn: (log) => logger.warn(log.msg),
error: (log) => logger.error(log?.msg),
},
});
try {
await client.connect();
} catch (error) {
throw new Error((error as { responseText: string }).responseText, { cause: error });
}
/**
[
{
// https://imapflow.com/global.html#FetchMessageObject
seq: Number,
uid: Number,
envelope: {
// https://imapflow.com/global.html#MessageEnvelopeObject
},
id: 'md5-like-hash-string',
source: Buffer,
}
]
*/
const mails: any[] = [];
const lock = await client.getMailboxLock(folder);View on GitHub (pinned to bed535e087)
Solutions
- Verify IMAP host/port and that port 993 is reachable from the RSSHub host.
- Use an app-specific password for providers that require it (Gmail, Yahoo, iCloud).
- If `config.proxyUri` is set, ensure it is HTTP/HTTPS (not socks5h).
- Improve the error cast so a missing `responseText` falls back to the real error message (see exampleFix).
Example fix
// before
try {
await client.connect();
} catch (error) {
throw new Error((error as { responseText: string }).responseText, { cause: error });
}
// after: fall back to a useful message when responseText is absent
try {
await client.connect();
} catch (error) {
const e = error as { responseText?: string; message?: string };
const message = e.responseText || e.message || 'IMAP connection failed';
throw new Error(message, { cause: error });
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight reachability check before IMAP connect.
import net from 'node:net';
async function imapReachable(host: string, port: number, timeoutMs = 5000): Promise<boolean> {
return await new Promise((resolve) => {
const socket = net.createConnection({ host, port });
socket.setTimeout(timeoutMs);
socket.once('connect', () => { socket.end(); resolve(true); });
socket.once('error', () => resolve(false));
socket.once('timeout', () => { socket.destroy(); resolve(false); });
});
} Type guard
function hasResponseText(e: unknown): e is { responseText: string } {
return typeof (e as any)?.responseText === 'string' && (e as any).responseText.length > 0;
} Try / catch
try {
await client.connect();
} catch (error) {
const e = error as { responseText?: string; message?: string };
const message = e.responseText || e.message || 'IMAP connection failed';
throw new Error(message, { cause: error });
} Prevention
- Use app passwords for providers that require them.
- Confirm port 993 is reachable from the RSSHub host before configuring the route.
- Always fall back to `error.message` when a typed field is missing.
When it happens
Trigger: Wrong IMAP host/port; bad credentials (auth rejected); network/firewall blocking 993; TLS mismatch; proxy misconfiguration (`config.proxyUri` unsupported scheme — note socks5h is unsupported per the comment); the IMAP server returns an error object without `responseText`.
Common situations: App password vs. regular password (Gmail/Yahoo require app passwords); corporate firewall blocking IMAP; host set to a POP3 server; expired credentials; `responseText` undefined producing a useless message.
Related errors
- Email Inbox RSS is disabled due to the lack of <a href="http
- Failed to fetch data from Kemono: ${error instanceof Error ?
- 日报数据不存在或为空
- Failed to fetch data from API
- Failed to fetch channel data from Castbox
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/9ca83748828e3a73.
Report an issue: GitHub.