Code RoomShared locale cache race condition
HardPrep Room Coding #4429

Shared locale cache race condition

Vibe & agenticConcurrencySenior–Staff~19 min

This Cloudflare Worker (TypeScript) caches a per-request locale on a shared module object to avoid recomputing it. Under load, some responses render in the wrong language. The AI said module scope is a fine cache. Explain the concurrency bug.

Implement
render_locales(accept_language_headers: list[str], supported: list[str]) → list[str]
Examples
in[["fr-CA,fr;q=0.9,en;q=0.8","en-US,en;q=0.9",""],["en","fr","de"]]out["fr","en","en"]
in[[" FR ; q=0.7 , en"],["en","fr"]]out["fr"]
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.

0:00 of about 19 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.