Code Room
Code reviewMediumcr-g641
Subject Connection pool leakLevel Mid–Senior~20 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Node.js function using a node-postgres pool.

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.

Talk through your review
Code to reviewjs
async function getProfile(pool, userId) {  const client = await pool.connect();  const { rows } = await client.query(    'SELECT * FROM profiles WHERE user_id = $1',    [userId]  );  if (rows.length === 0) {    throw new NotFoundError('no profile');  }  client.release();  return rows[0];}
Run or narrate your approach, then ask the coach.