A handler creates a new debounced function on every keystroke and immediately calls it. Each call eventually makes a request. Why didn’t debouncing help, and what would you do with the pending timer when the input disappears?
Every wrapper has its own timer state, so the wrappers do not cancel each other. Create one stable wrapper for the intended lifetime, pass the latest input as an argument, and cancel any pending invocation at teardown. Handle already-started requests separately if they can race or must be aborted.
What a Strong Answer Covers
Identify one shared timer per debounced wrapper.
Distinguish cancelling a timer from cancelling in-flight requests.
Follow-up Interview Question · When might throttling be a better fit than debouncing?