Fix async race in fetchWithCache
fetchWithCachePublic 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.
- Aced: ElevenLabs senior full-stack (frontend-leaning) interview experience, 2026
One senior account describes a live round that included fixing a practical problem together with the interviewer. This async-race fix is a practice version of that round shape, not the reported problem.
- Taro: Stripe frontend engineer interview, 2023
One Stripe front end engineer account lists a round on bug finding within an unknown project. This debug exercise practises that shape in a small codebase; it is not the reported bug.
- Taro: GitLab front end engineer interview, 2024
The merge request in this account was a small Vue app with an API call; the candidate cached the data in the component and cut unnecessary API calls. This debug drill practises stopping duplicate requests, not the reported app.
- Taro: Cloudflare frontend engineer interview, Portugal, 2025
Besides a TypeScript task, the technical stages included tasks on debugging and solving small problems, which the account does not name. This exercise practises debugging; it is not one of the reported tasks.
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
Solution
The fixed code
const cache = new Map();
const inflight = new Map();
export default async function fetchWithCache(key, fetcher){
if(cache.has(key)) return cache.get(key);
if(inflight.has(key)) return inflight.get(key);
const p = Promise.resolve()
.then(() => fetcher())
.then(res => {
cache.set(key, res);
return res;
})
.finally(() => {
inflight.delete(key);
});
inflight.set(key, p);
return p;
}
Similar questions
Guides
Preparing for interviews? Use Frontend Coding Challenges first, then move into a concrete Study Plan before targeted Company Prep.
Built in public
The code behind FrontendAtlas lives on GitHub. A star helps other frontend engineers find it.