There is a Vue component for a client search panel in the browser. Stack and runtime mode: Vue 3.5 Composition API, TypeScript 5.8, Vite 5, browser, ESM. The component receives a search string, automatically requests a customer card through the passed function fetchCustomer(query, signal), and shows one of the states: loading, error, or the found card.
Functional requirements:
query.name and city must be shown.API contract:
fetchCustomer(query: string, signal: AbortSignal): Promise<Customer>.DOMException and name === 'AbortError'.Failed to load customer.Assumptions and reproduction:
AbortController is used.fetchCustomer that responds to different strings with different delays.query = "anna", then quickly change it to "annabelle" so that the first request finishes later or fails after the second one has started.Below is the diff from the PR. A review is needed to find defects.
Vue 3.5 Composition API, TypeScript 5.8, Vite 5, browser, ESM; AbortController is required in the execution environment.
Use line comments to explain the problem, its impact, the fix and how to test it.