fix: guard markdownToHtml in the HTML fallback path

A throw from the converter used to escape the try/catch and drop the
message; degrade to plain text for that chunk instead.
This commit is contained in:
RRRosmontis
2026-09-02 16:10:48 +08:00
parent cecb655a4b
commit 20898d5d21
2 changed files with 13 additions and 2 deletions
+7 -1
View File
@@ -828,7 +828,13 @@ export class TelegramBridge {
async deliverHtml(chatId, markdown) {
const chunks = splitMessage(markdown, this.maxMessageLength);
for (const chunk of chunks) {
const html = markdownToHtml(chunk);
let html;
try {
html = markdownToHtml(chunk);
}
catch {
html = chunk; // Pathological markdown input: degrade to plain text instead of dropping.
}
try {
await this.withRetry(() => this.client.sendMessage(chatId, html, 'HTML'));
}
+6 -1
View File
@@ -954,7 +954,12 @@ export class TelegramBridge {
private async deliverHtml(chatId: number, markdown: string): Promise<void> {
const chunks = splitMessage(markdown, this.maxMessageLength)
for (const chunk of chunks) {
const html = markdownToHtml(chunk)
let html: string
try {
html = markdownToHtml(chunk)
} catch {
html = chunk // Pathological markdown input: degrade to plain text instead of dropping.
}
try {
await this.withRetry(() => this.client.sendMessage(chatId, html, 'HTML'))
} catch {