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
Software Engineering Fundamentals
Frontend Engineer
EPAM Systems
November 29, 2026
Frontend Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

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
debounce
AbortController
race conditions
client caching
accessibility
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions