Code RoomDownstream call ignores request deadline
HardPrep Room Coding #1942

Downstream call ignores request deadline

Code reviewCode quality & reviewSenior–Staff~22 min

Review this Go handler. The incoming request has a 200ms deadline on `ctx`, but tail latency on the upstream still spikes to seconds.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1func handler(w http.ResponseWriter, r *http.Request) {
2 ctx := r.Context() // carries a 200ms deadline
3 id := r.URL.Query().Get("id")
4 user, err := lookupUser(ctx, id)
5 if err != nil {
6 http.Error(w, "not found", 404)
7 return
8 }
9 // enrich from a slow downstream
10 resp, _ := http.Get("https://profiles.internal/u/" + user.ID)
11 defer resp.Body.Close()
12 io.Copy(w, resp.Body)
13}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.