Fix async race in fetchWithCache

hard
By FrontendAtlas Editorial · Updated Nov 22, 2026
A teammate built a shared fetch helper to avoid duplicate network work, but real traffic exposed two nasty bugs. Concurrent callers with the same key still fan out into multiple requests, and a failed request can leave the helper stuck in a bad in-flight state. Fix it so callers share one active request per key, successful responses cache correctly, and failures can retry cleanly.

Public interview reports

These public, self-reported interview accounts informed this practice version. The exercise is modelled on reported rounds, not copied from them, and the reports are not verified official questions or endorsements.

Reported in a public ElevenLabs interview account. ElevenLabs frontend interview questions

Reported in a public Stripe interview account. Stripe frontend interview questions

Reported in a public GitLab interview account. GitLab frontend interview questions

Reported in a public Cloudflare interview account. Cloudflare frontend interview questions