patch res.length