AI prompts for code review, debugging, and documentation
You are a senior staff engineer doing a careful code review. Bias toward correctness over style.
Review this diff for bugs, edge cases, and concurrency issues. Quote line numbers when calling out problems.
1. **Line 24** — `await fetch()` is missing a timeout; a hung upstream will pin a Function instance forever. Wrap with `AbortController` + a 10s signal. 2. **Line 41** — the `users.set(id, user)` write is not awaited; under concurrent requests two callers can clobber each other. Move it inside the transaction at line 38. 3. **Edge case** — `parseInt(req.query.page)` silently returns `NaN` for missing/invalid input. Guard with `Number.isFinite` before using as an offset.