SourceR85 commented on code in PR #9193:
URL: https://github.com/apache/pouchdb/pull/9193#discussion_r3043502363


##########
packages/node_modules/pouchdb-errors/src/index.js:
##########
@@ -92,10 +98,6 @@ function generateErrorFromResponse(err) {
     err.message = err.message || err.reason;
   }
 
-  if (!('stack' in err)) {
-    err.stack = (new Error()).stack;
-  }
-

Review Comment:
   Don't remove stack property: this change will break the API (probably 
affecting some plugins) and need to be discussed without interference of other 
changes.
   Usually we publish at least one version with a deprecation notice, so 
everyone has a chance to adopt to that change before there code break.



##########
packages/node_modules/pouchdb-errors/src/index.js:
##########
@@ -70,9 +76,9 @@ function createError(error, reason) {
 function generateErrorFromResponse(err) {
 
   if (typeof err !== 'object') {
-    var data = err;
-    err = UNKNOWN_ERROR;
-    err.data = data;
+    const newErr = Object.assign({}, UNKNOWN_ERROR);  // Clone to avoid 
mutation
+    newErr.data = err;
+    err = newErr;

Review Comment:
   can be reduced to a single instruction:
   ```suggestion
       err = Object.assign({}, UNKNOWN_ERROR, { data: err });  // Clone to 
avoid mutation
   ```



##########
packages/node_modules/pouchdb-errors/src/index.js:
##########
@@ -60,6 +60,12 @@ function createError(error, reason) {
     pouchError[name] = error[name];
   }
 
+  try {
+    void pouchError.stack;
+  } catch (e) {
+    // Silently ignore inaccessible stack
+  }
+

Review Comment:
   Remove it: it's a noop.
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to