Files
orca/src/main/git/max-buffer-overflow.ts
T
Jinjing 256e0ef81a Handle buffer overflows gracefully and truncate diffs fairly (#5083)
- Gracefully fall back to file-name summaries when staged diffs exceed
  node/ssh execution maxBuffer limits, preventing generation failures.
- Split oversized diffs by file and allocate budget via water-filling,
  ensuring single huge files do not starve smaller human changes.
- Clip truncated diff sections on line boundaries to avoid half-lines.
2026-06-09 23:56:36 -07:00

23 lines
654 B
TypeScript

export function isMaxBufferOverflowError(error: unknown): boolean {
if (!error || typeof error !== 'object') {
return false
}
const maybeError = error as { code?: unknown; message?: unknown }
if (maybeError.code === 'ENOBUFS') {
return true
}
return typeof maybeError.message === 'string' && /\bmaxBuffer\b/i.test(maybeError.message)
}
export function describeMaxBufferOverflowError(error: unknown): string {
if (error && typeof error === 'object') {
const message = (error as { message?: unknown }).message
if (typeof message === 'string' && message.length > 0) {
return message
}
}
return String(error)
}