From 5db01715d201a87e879e718c4124a43612541631 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 4 Dec 2024 16:10:57 +0900 Subject: [PATCH] fix(pouchdb-error): do not inherit error properties by copying from parent error manually to avoid Hermes from causing an error. See https://github.com/facebook/hermes/issues/1496 --- .../node_modules/pouchdb-errors/src/index.js | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/packages/node_modules/pouchdb-errors/src/index.js b/packages/node_modules/pouchdb-errors/src/index.js index 1aad79dd59..a863551aaf 100644 --- a/packages/node_modules/pouchdb-errors/src/index.js +++ b/packages/node_modules/pouchdb-errors/src/index.js @@ -44,26 +44,13 @@ var MISSING_STUB = new PouchError(412, 'missing_stub', 'A pre-existing attachmen var INVALID_URL = new PouchError(413, 'invalid_url', 'Provided URL is invalid'); function createError(error, reason) { - function CustomPouchError(reason) { - // inherit error properties from our parent error manually - // so as to allow proper JSON parsing. - var names = Object.getOwnPropertyNames(error); - for (var i = 0, len = names.length; i < len; i++) { - if (typeof error[names[i]] !== 'function') { - this[names[i]] = error[names[i]]; - } - } - - if (this.stack === undefined) { - this.stack = (new Error()).stack; - } - - if (reason !== undefined) { - this.reason = reason; - } + // inherit error properties from our parent error manually + // so as to allow proper JSON parsing. + var err = new PouchError(error.status, error.name, error.message); + if (reason !== undefined) { + err.reason = reason; } - CustomPouchError.prototype = PouchError.prototype; - return new CustomPouchError(reason); + return err; } function generateErrorFromResponse(err) {