Code Room
Vibe codingMediumvc-g343
Subject Ai code reviewLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development, Telecom

Question

An AI wrote this Go helper to fetch and parse a record from a backend over a pooled TCP connection. It passes tests but the service runs out of file descriptors after a few hours under load. Find the leak, when it triggers, and the fix.

go
func fetch(addr string, req []byte) (*Record, error) {    conn, err := net.Dial("tcp", addr)    if err != nil {        return nil, err    }    if _, err := conn.Write(req); err != nil {        return nil, err    }    resp, err := io.ReadAll(conn)    if err != nil {        return nil, err    }    defer conn.Close()    return parse(resp)}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.