Stop Asking Candidates to Hand-Write Promise.all — Give Them the Batch-Off-Shelf Problem Instead
A colleague who just completed his first year on the team came to me for his first performance review after probation. Near the end, he half-jokingly said:
"Boss, during my interview I hand-wrote Promise.all, debounce/throttle, deep copy, LRU cache, and talked about React Fiber for half an hour. After a year on the job, the most I've written is tables, forms, and modals."
I laughed and didn't respond. Because on his interview day, I was the one who set those questions 😁.
It's ironic. I've been in this industry for nearly ten years, and I know full well there's a river between interview questions and actual work. But when my turn came to be the interviewer, I still pulled those same questions from the question bank.
Let's talk about this today, and also about how I changed afterwards 😃.
Why does everyone use these questions?
It's not that interviewers don't know these questions are disconnected from work. The problem is the low cost of giving these questions 🤔
Low question-preparation cost
Promise.all, debounce, deep copy — standard answers are everywhere online. The interviewer doesn't need to prepare; just pick and use them. Whether the answer is right or wrong is obvious at a glance, without requiring the interviewer to have deep business understanding.
Easy comparison of results
Interview five people a day, everyone writes the same question. Compare side by side and you can easily tell who has solid fundamentals and who doesn't. It's also convenient when HR and higher-ups want to see the evaluation notes.
Interviewers themselves are short on time
Most interviewers in Chinese teams are also frontline developers. They write features during the day and schedule interviews at night. Designing a business-specific question for each candidate isn't realistic.
The result is an unspoken consensus: candidates memorize answers, interviewers test memorization, and nobody mentions it after hiring 🤷♂️.
The problem isn't Promise.all itself
To be fair, Promise.all isn't a bad question. Async concurrency appears in frontend business every day.
The standard answer in interviews usually looks like this 👇:
// Interview standard answer
function promiseAll<T>(promises: Array<T | Promise<T>>): Promise<T[]> {
return new Promise((resolve, reject) => {
const results: T[] = [];
let count = 0;
if (promises.length === 0) return resolve(results);
promises.forEach((p, i) => {
Promise.resolve(p).then((value) => {
results[i] = value;
count += 1;
if (count === promises.length) resolve(results);
}, reject);
});
});
}
Being able to write this shows the candidate knows to store results by index, handle empty arrays, and reject the whole thing when one fails.
But after joining, the real need looks like this:
The operator selects 300 products in the product list and clicks batch off-shelf.
If you use Promise.all to send all at once, several problems occur 👇
The truly useful skill is being able to write Promise.all correctly inside that kind of scenario.
What I do now
Later I changed the written test. No more hand-writing Promise.all. Instead I give the batch off-shelf scenario above and require: controllable concurrency, aggregation of partial failures, user cancellation, and separate retry for failures.
No need to write it perfectly from memory. Just write the main structure in 30 minutes and explain the reasoning behind each design choice. Here's the reference answer I have in mind:
// Concurrency control + partial failure aggregation + cancellation
型 TaskResult<T> =
| { status: 'fulfilled'; index: number; value: T }
| { status: 'rejected'; index: number; reason: unknown };
interface BatchOptions {
concurrency?: number;
signal?: AbortSignal;
onProgress?: (done: number, total: number) => void;
}
export async function runBatch<I, T>(
items: readonly I[],
worker: (item: I, signal: AbortSignal) => Promise<T>,
{ concurrency = 5, signal, onProgress }: BatchOptions = {},
): Promise<TaskResult<T>[]> {
const results: TaskResult<T>[] = new Array(items.length);
const controller = new AbortController();
let cursor = 0;
let done = 0;
// Abort all in-flight requests when external signal cancels
const abort = () => controller.abort(signal?.reason);
if (signal?.aborted) abort();
signal?.addEventListener('abort', abort, { once: true });
async function lane(): Promise<void> {
while (cursor < items.length && !controller.signal.aborted) {
const index = cursor++; // safe because single-threaded, no two lanes get same index
try {
const value = await worker(items[index], controller.signal);
results[index] = { status: 'fulfilled', index, value };
} catch (reason) {
// single failure doesn't affect others, record for caller to aggregate
results[index] = { status: 'rejected', index, reason };
} finally {
done += 1;
onProgress?.(done, items.length);
}
}
}
try {
const lanes = Array.from({ length: Math.min(concurrency, items.length) }, lane);
await Promise.all(lanes);
} finally {
signal?.removeEventListener('abort', abort);
}
// For cancelled tasks, mark unexecuted ones so result array has no holes
for (let i = 0; i < items.length; i++) {
results[i] ??= { status: 'rejected', index: i, reason: new DOMException('Aborted', 'AbortError') };
}
return results;
}
Business-side call:
// Batch off-shelf framework
async function batchOffShelf(productIds: string[], signal: AbortSignal) {
const results = await runBatch(
productIds,
(id, s) =>
fetch(`/api/products/${id}/off-shelf`, { method: 'POST', signal: s }).then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return id;
}),
{ concurrency: 6, signal, onProgress: (d, t) => updateProgressBar(d / t) },
);
const failed = results.filter(
(r): r is Extract<TaskResult<string>, { status: 'rejected' }> => r.status === 'rejected',
);
const succeeded = results.length - failed.length;
// Keep failed ids and provide separate retry in a modal instead of making the operator redo the whole batch
return { succeeded, failedIds: failed.map((r) => productIds[r.index]) };
}
This question distinguishes a lot: whether the candidate thinks of a concurrency limit, whether they think of partial failure, whether they know AbortController, whether types are written strictly, and whether the result array is clean after cancellation.
Most importantly, this is code he would actually write in his first month on the job.
After using this set of questions, my feeling is: the candidate who memorized the most answers doesn't necessarily write the best; instead, those who have spent years on backend systems and been burned by batch operations will immediately ask: does the backend have rate limiting? Should failures be retried?
CRUD is not shameful
Back to that colleague. He thinks a year of writing CRUD is a waste. I understand the feeling, but it's only half right.
CRUD in backend systems, when done well, has just as many pitfalls as interview questions 👇
These problems have all appeared in our online defect records. Someone who can handle all of them cleanly may write CRUD with real skill.
So the advice I gave him later: Don't look down on simple tasks; do every simple task so well that nobody can find flaws. A year later, when you go to interview again, your project experience will read: designed a batch operation framework covering 20+ business scenarios, cutting partial failure rate from the top of the operations complaint list to zero.
That kind of experience is worth more than hand-writing Promise.all ten times 🫡.
Final words
The disconnect between interviews and work is not one person's fault; it's an industry-wide inertia to save effort. Interviewers want easy questions, candidates want effective memorization, and everyone stays in a low-cost equilibrium.
But if you're an interviewer, try putting the questions from your question bank into real business scenarios. Spend half an hour more preparing, and the people you hire will be much more reliable. If you're a candidate, you still have to memorize questions, but don't think that's enough. What really caps your salary is how many pitfalls you've filled in your CRUD work.
Okay, that's it for today 🫡
If you like my articles, follow my WeChat public account: 【前端技术官】.
Main topics: Frontend Architecture · AI Programming · Workplace Insights · Developer Growth
Scan to follow 👆
Irregular updates, no spam, only genuinely useful content.
Top 1 from juejin.cn, machine-translated. The original thread is authoritative.
I'm already unemployed. While waiting for a job at home, I used AI to make a mini-program: specifically for treating couple quarrels and family discord [melon-eating onlookers].