跪拜 Guibai
← All articles
Frontend · JavaScript · Programmer

Stop Asking Candidates to Hand-Write Promise.all — Give Them the Batch-Off-Shelf Problem Instead

By ErpanOmer ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The interview gap between memorized textbook answers and production batch operations wastes hiring cycles and admits developers who can't handle real async loads. Replacing theory quizzes with scenario-based problems that mirror first-month work gives engineering managers a much stronger predictor of on-the-job performance.

Summary

A frontend interviewer with nearly a decade of experience admits he used to ask candidates to hand-write Promise.all, debounce, deep copy, and LRU cache, plus explain React Fiber. One year into the job, a junior colleague pointed out that the most he'd written was tables, forms, and modals. The interviewer's response: the standard questions are cheap to grade, easy to compare across candidates, and don't require the interviewer (often a busy frontline dev) to design business-specific problems.

The real problem isn't Promise.all itself. The classic implementation tests whether someone can store results by index, handle empty arrays, and reject on first failure. But production demands look very different: an operator selecting 300 products to batch off-shelf. Sending all 300 requests at once with Promise.all creates a mess. What matters is being able to adapt the pattern into a controlled batch runner with concurrency limits, partial failure aggregation, cancellation via AbortController, and retryable failures.

Now that interviewer uses a single realistic scenario: implement a batch off-shelf feature with concurrency control, partial failure summary, cancellation, and separate retry. The reference solution, provided in full, uses an AbortController, a lane-based worker pool, and a result array that distinguishes fulfilled and rejected tasks. Candidates who've actually built backend batch systems ask the right questions up front, like whether the backend rate-limits or whether failures should retry. The article closes with a defense of CRUD: doing it well requires solving edge cases that show up in real defect logs, and a year of polished CRUD beats ten hand-written Promise.all answers.

Takeaways
— Chinese frontend interview questions typically require hand-writing Promise.all, debounce/throttle, deep copy, and LRU cache, plus explaining React Fiber.
— Interviewers choose these questions because they require minimal prep, are easy to grade, and work for comparing many candidates quickly.
— A naive Promise.all fails when sending 300 concurrent requests for batch operations like off-shelf, causing connection overload, rate limiting, and no way to handle partial failures.
— The recommended replacement interview task: given a batch off-shelf scenario, require the candidate to implement concurrency control, partial failure aggregation, user cancellation via AbortController, and separate retry.
— The provided reference solution uses a lane-based worker pool (default concurrency 5), an AbortController to cancel all in-flight requests, and a result array with fulfilled/rejected statuses that marks unexecuted tasks as aborted.
— Candidates with real backend batch experience naturally ask about backend rate limiting and failure retry, distinguishing them from memorization-focused candidates.
— Doing CRUD well in backend systems involves edge cases like pagination consistency, permission checks, and field validation that all appear in production defect logs.
— The author advises junior developers to treat simple tasks as opportunities to eliminate all defects, since a project history of a batch framework with zero partial failures is worth more than memorized algorithm answers.
Conclusions

The interview question is a coordination problem, not a knowledge problem: both sides settle into a low-cost equilibrium where interviewers reuse standard problems and candidates memorize them, and no one changes because changing costs time.

A scenario-based question that mirrors actual first-month code shifts the interview from testing recall to testing design judgement under constraints.

The article implicitly argues that the ability to integrate standard library primitives like AbortController into a realistic batch workflow is a better signal of seniority than the ability to write a textbook implementation from memory.

Defending CRUD work as a training ground for edge-case thinking directly counters the common junior complaint that CRUD is busywork, pointing to concrete defect patterns as evidence.

Concepts & terms
AbortController
A browser/Node API that lets you signal cancellation to one or more asynchronous operations. In the batch runner, it is used to cancel all in-flight requests when the user aborts, preventing wasted work and giving consistent cleanup.
Concurrency control batch runner
A pattern that limits how many async tasks run at once, collecting per-task results (success or failure) into a structured array, rather than failing the whole batch on the first error. It supports partial failure reporting and retry.
Partial failure aggregation
Instead of rejecting the entire Promise.all when one request fails, a batch runner records each failed task separately, allowing the caller to summarize and retry only the failed items without re-running successful ones.
Lane-based worker pool
An implementation approach for limited concurrency where a fixed number of worker loops ('lanes') pull items from a shared cursor, each processing one at a time until the queue is empty. It avoids spawning unlimited promises.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗