fix: 修复内存溢出问题,compact 时清理持久增长数据结构

- compact 时清理 contentReplacementState(seenIds/replacements)
- logError() 使用 shortErrorStack 替代完整 err.stack,减少 GC 压力
- permissionDenials 每次 submitMessage 清空,防止无限增长
- SSE 缓冲区添加 1MB 上限,防止畸形数据无限累积

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-01 22:24:18 +08:00
parent a81995052f
commit ab0bbbc4b5
5 changed files with 35 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ import {
import { CACHE_PATHS } from './cachePaths.js'
import { stripDisplayTags, stripDisplayTagsAllowEmpty } from './displayTags.js'
import { isEnvTruthy } from './envUtils.js'
import { toError } from './errors.js'
import { toError, shortErrorStack } from './errors.js'
import { isEssentialTrafficOnly } from './privacyLevel.js'
import { jsonParse } from './slowOperations.js'
@@ -175,7 +175,7 @@ export function logError(error: unknown): void {
return
}
const errorStr = err.stack || err.message
const errorStr = shortErrorStack(err)
const errorInfo = {
error: errorStr,