Partial failure in multi-write
Review this JavaScript multi-write notifier.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1async function notifyAll(userIds, message) {
2 if (!userIds.length) return [];
3 const results = await Promise.all(
4 userIds.map((id) => pushService.send(id, message))
5 );
6 await db.markNotified(userIds);
7 return results;
8}
9
10// caller
11async function broadcast(segment, message) {
12 const ids = await db.usersInSegment(segment);
13 const sent = await notifyAll(ids, message);
14 metrics.incr("push.sent", sent.length);
15 return sent;
16}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.