fix: avoid invalid UTF-16 in truncation (#567)

This commit is contained in:
Peter Steinberger committed 2026-01-09 15:19:49 +01:00
1 parent fd535a50d3
commit 63f5fa47de
7 files changed
+70 -7

No files matched your search

+5 -1
View File
@@ -61,6 +61,7 @@ import {
} from "../routing/resolve-route.js";
import { resolveThreadSessionKeys } from "../routing/session-key.js";
import type { RuntimeEnv } from "../runtime.js";
import { truncateUtf16Safe } from "../utils.js";
import { loadWebMedia } from "../web/media.js";
import { resolveDiscordAccount } from "./accounts.js";
import { chunkDiscordText } from "./chunk.js";
@@ -1017,7 +1018,10 @@ export function createDiscordMessageHandler(params: {
}
if (shouldLogVerbose()) {
const preview = combinedBody.slice(0, 200).replace(/\n/g, "\\n");
const preview = truncateUtf16Safe(combinedBody, 200).replace(
/\n/g,
"\\n",
);
logVerbose(
`discord inbound: channel=${message.channelId} from=${ctxPayload.From} preview="${preview}"`,
);