Code Room
Vibe codingHard
Question
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.
const ctx = { locale: "en" }; export default { async fetch(req: Request): Promise<Response> { ctx.locale = detectLocale(req.headers.get("accept-language")); const greeting = await loadGreeting(ctx.locale); // async gap return new Response(render(greeting, ctx.locale)); },};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.
Learn the concepts
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.