Time: 0:00
Test a custom input to verify an edge case (e.g. empty lists, negative numbers, duplicates).
This bug belongs to the async and race conditions pattern
A missing await, results in the wrong order, and updates that overwrite each other under load.
What went wrong: cache is set only after the slow load finishes. Calls that arrive in the meantime see null and each start another load.
The fix: store the promise in cache straight away, before any await, so later callers wait for the same load.
Remember: to stop duplicate async work, cache the promise, not the result.
The pattern behind it: async and race conditions.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/c820f1ae-7487-4bd8-9991-e8ae7388da56" title="Debugging challenge: Cached loader runs 3 times instead of once" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/c820f1ae-7487-4bd8-9991-e8ae7388da56">TryBugHunt</a></p>