From bcbb096b32686ecad6cd34235358ed6f2217d4f0 Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Mon, 25 Sep 2023 10:10:10 +0200 Subject: [PATCH] Do not directly set Error properties. Fixes https://github.com/follow-redirects/follow-redirects/issues/231 --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 057c6b1..0818005 100644 --- a/index.js +++ b/index.js @@ -597,8 +597,16 @@ function createErrorType(code, message, baseClass) { // Attach constructor and set default properties CustomError.prototype = new (baseClass || Error)(); - CustomError.prototype.constructor = CustomError; - CustomError.prototype.name = "Error [" + code + "]"; + Object.defineProperties(CustomError.prototype, { + constructor: { + value: CustomError, + enumerable: false, + }, + name: { + value: "Error [" + code + "]", + enumerable: false, + }, + }); return CustomError; }