Add error handling for file handle close operation

- Wrap fileHandle.close() in try-catch to prevent masking original errors
- Log close errors without throwing to preserve error context

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-27 08:46:51 +00:00
parent e1ce0f3fa9
commit d30eb2008c

View File

@ -31,7 +31,12 @@ export async function writeFileWithLock(
throw new Error(`Failed to create file ${filePath}: ${errorMessage}`); throw new Error(`Failed to create file ${filePath}: ${errorMessage}`);
} finally { } finally {
if (fileHandle) { if (fileHandle) {
await fileHandle.close(); try {
await fileHandle.close();
} catch (closeError) {
// Log close error but don't throw to avoid masking the original error
Logger.error(`Failed to close file handle for ${filePath}:`, closeError);
}
} }
} }
} }