记录 Markdown 渲染失败信号

在错误边界捕获时记录脱敏错误类型

保留消息正文回退且不输出敏感内容
This commit is contained in:
2026-09-04 16:09:52 +08:00
parent 1de48ad5a6
commit 16879ab390
@@ -28,8 +28,14 @@ export class MarkdownErrorBoundary extends Component<
return { hasError: true };
}
componentDidCatch(_error: unknown, _errorInfo: ErrorInfo) {
componentDidCatch(error: unknown, errorInfo: ErrorInfo) {
// Keep the original message visible without logging its potentially sensitive content.
const errorName =
error instanceof Error && error.name ? error.name : 'UnknownError';
console.error('[chat-markdown] render failed', {
errorName,
hasComponentStack: Boolean(errorInfo.componentStack?.trim()),
});
}
componentDidUpdate(prevProps: MarkdownErrorBoundaryProps) {