Code RoomMap modified during iteration
MediumPrep Room Coding #2211

Map modified during iteration

Code reviewConcurrencyMid–Senior~24 min

Review this TypeScript in-memory session store with periodic cleanup.

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 24 min
Mark a line and say what kind of problem it is.0 findings
1const sessions = new Map<string, Session>();
2 
3async function reap() {
4 for (const [id, s] of sessions) {
5 if (s.expired()) {
6 await persistToDisk(s); // async flush before eviction
7 sessions.delete(id);
8 }
9 }
10}
11setInterval(reap, 1000);
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.