Build a Debounced Typeahead That Ignores Stale Search Responses
Last updated: November 29, 2026
Quick Overview
Implement the client logic for a product search box that waits until the user pauses typing, cancels in-flight requests when the query changes, never shows results for an older query after a newer one, and caches recent queries.
EPAM Systems
November 29, 20260
0
0 solved
Implement the client logic for a product search box that waits until the user pauses typing, cancels in-flight requests when the query changes, never shows results for an older query after a newer one, and caches recent queries.
Frontend roles at EPAM (React and Angular on client e-commerce and portal projects) usually include a practical JavaScript round on async behavior. The interviewer checks debounce, out-of-order response handling with AbortController, and attention to accessibility and empty states.
What the Interviewer Expects
- Debounce input so requests fire only after a pause
- Abort the previous request when a new one starts
- Guard against out-of-order responses even if abort is not honored
- Cache results per normalized query with a size bound
- Handle empty input, errors and loading state, with accessible markup
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you write this as a React hook, and what goes in the effect cleanup?
- How would you do the same with RxJS in Angular (switchMap)?
- How would you test the timing behavior without real waits?
- What ARIA roles and keyboard behavior does a combobox need?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Wait 250 ms after the last keystroke. Trim and lowercase the query; under 2 characters clears results without a request. Show a loading state, render results, show an error message on failure. Results...
High-Level Design
Three mechanisms. A debounce timer reset on each input. An AbortController per request, aborted when a new request starts, which frees the network and rejects the old promise with AbortError. A mo...