mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: separate countFileLines and isBinaryFile calls for accurate error handling
- Split Promise.all() into sequential calls to isolate error sources - countFileLines is called first and should not fail for valid files - Only isBinaryFile errors are caught and handled by treating file as binary - This ensures RangeError from isBinaryFile doesn't incorrectly attribute to countFileLines - Fixes issue where binary file detection errors were masking actual file reading problems
This commit is contained in:
parent
6796e1a285
commit
7718bef258
1 changed files with 5 additions and 4 deletions
|
|
@ -436,14 +436,15 @@ export async function readFileTool(
|
|||
let totalLines: number
|
||||
let isBinary: boolean
|
||||
|
||||
// First, count the file lines (this should not fail for valid files)
|
||||
totalLines = await countFileLines(fullPath)
|
||||
|
||||
// Then check if it's binary, with error handling specific to isBinaryFile
|
||||
try {
|
||||
const results = await Promise.all([countFileLines(fullPath), isBinaryFile(fullPath)])
|
||||
totalLines = results[0]
|
||||
isBinary = results[1]
|
||||
isBinary = await isBinaryFile(fullPath)
|
||||
} catch (error) {
|
||||
// If isBinaryFile throws an error (e.g., RangeError), treat the file as binary
|
||||
console.warn(`Error checking if file is binary for ${relPath}:`, error)
|
||||
totalLines = await countFileLines(fullPath)
|
||||
isBinary = true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue