All 35 Bugs /
0/35 Fixed ✓
JavaScriptHard~15 min

Race Condition in Live Search Fetch

What's Broken (Symptom)

Typing `"re"` (slow 60ms server reply) then `"react"` (fast 15ms reply) leaves stale `"re"` results displayed last!

Expected Behavior

  • Cancel previous in-flight fetches using `AbortController` or ignore stale responses via request sequence tracking.
  • Only the latest query (`"react"`) is allowed to update `latestResult`.
  • Aborted requests must not overwrite `latestResult` or crash with unhandled rejection.

Debugging Hints (0/2 used)

Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.

Root Cause Breakdown

Pass all 3 automated verification checks on the right to unlock the full Root Cause explanation.

Automated Bug Verification

3 Checks Ready
  • Fast newer search is never overwritten by slow older searchRun "re" (70ms) followed by "react" (15ms); final latestResult must be ["react-docs"].
  • Passes AbortSignal to fetchFn and aborts prior requestVerify previous signal becomes aborted when a second search starts.
  • Returns normal results for a single search querySingle call still resolves and updates latestResult cleanly.
bugfix.js
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.