Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Leaked resources: files, connections, goroutines card 1 of 6

Green tests, then 'too many open files'

builds on: Error handling idioms across languages
You asked the agent to add an export endpoint that reads rows from the database and writes them to a file. The diff is tidy, tests are green, and it ships. Three days later the service fails with `too many open files`, and requests hang waiting for a database connection. A restart fixes it, for about a day. Nothing in the diff looked wrong.
Terms on this card
too many open files
The OS error you get when a process has used up its file descriptor limit. Any further open or connect call fails.
the diff
The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are unchanged context.
the agent
The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
endpoint
A URL plus method (such as GET /items) that a web API answers requests on.
diff
The set of line changes between two versions of the code: removed lines start with '-', added lines with '+'.
Learn this step by step on Bytewise
Lesson goal: Spot files, connections and locks opened without `with`, try-with-resources or `defer`, as well as `defer` inside loops, goroutines blocked forever and contexts never cancelled. Explain why these pass tests but exhaust resources in production. · the whole lesson