The append method created a new WriteStream for every log chunk and resolved the promise on the end callback (data flushed) rather than the close event (fd released). Over many agent runs the leaked fds corrupted the fd table, causing child_process.spawn to fail with EBADF. Replace with fs.appendFile which properly opens, writes, and closes the fd before resolving. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4.8 KiB
4.8 KiB