This question evaluates a candidate's competence in building robust asynchronous utilities and form validation logic, covering retry/backoff strategies, error classification, per-attempt and overall timeouts, cancellation via AbortSignal, observable retry hooks, cross-field validators, state management, and accessibility considerations in JavaScript/TypeScript web applications. Category: Other / Miscellaneous; domain: web development and systems reliability in JavaScript/TypeScript; it is commonly asked because it probes both conceptual understanding of retry semantics, cancellation and validation constraints and practical implementation skills related to API ergonomics, error propagation, composable validators, and performance trade-offs.
You are implementing reusable utilities that are commonly needed in modern web apps:
The environment is JavaScript/TypeScript. You may assume access to standard Web APIs (e.g., AbortController), and you should design APIs that are ergonomic for both browser and Node runtimes.
Implement a higher-order utility wrapWithRetry(fn, options) that wraps a JavaScript/TypeScript function which may throw synchronously or return a rejected Promise.
Requirements:
AbortController
/
AbortSignal
so the entire retrying operation can be aborted.
AbortSignal
, allow passing a per-attempt signal into the function.
onRetry
).
Build a small form component with three text inputs and a tiny validation framework.
Requirements:
aria-invalid
,
aria-describedby
).
Provide a working example (TypeScript + React preferred) and explain your design choices and trade-offs.
Login required