mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 16:14:07 +00:00
Quick search fired one request per keystroke with no AbortController and no staleness check, so whichever response landed last won regardless of which query it belonged to. Typing an address slowly showed hits belonging to a short prefix while the box held the full string; retyping the same string in one go correctly showed none, which reads as "search works sometimes". advancedSearch already guarded every write with controller.signal.aborted. This gives searchEmails the same treatment, reusing the existing searchAbortController so the two search paths supersede each other rather than race. The catch branch is guarded too: without it a superseded request that rejects clears results belonging to the current query and surfaces a misleading error. Adds stores/__tests__/email-store-search-race.test.ts with three cases, all of which fail on main and pass with this change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>