Fix freeze when output text decoding fails (#1573)

This commit is contained in:
Zack Zhou 2026-02-09 17:17:36 +08:00 committed by GitHub
parent cc2c6d20fd
commit 042afe4157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,8 @@
*/
import Dish from "../../core/Dish.mjs";
import DishError from "../../core/errors/DishError.mjs";
import { CHR_ENC_SIMPLE_REVERSE_LOOKUP } from "../../core/lib/ChrEnc.mjs";
import Utils from "../../core/Utils.mjs";
import cptable from "codepage";
import loglevelMessagePrefix from "loglevel-message-prefix";
@ -98,7 +100,7 @@ async function bufferToStr(data) {
try {
str = cptable.utils.decode(data.encoding, new Uint8Array(data.buffer));
} catch (err) {
str = err;
str = new DishError(`Error decoding buffer with encoding ${CHR_ENC_SIMPLE_REVERSE_LOOKUP[data.encoding]}: ${err.message}`).toString();
}
}