digitalextremist commented on PR #358:
URL: https://github.com/apache/couchdb-nano/pull/358#issuecomment-3292230978

   I agree! But... some forest:
   
   The entire section is kinda moot and has code-smell, because it rests on 
`response.statusText` then never uses the complexity there, needless operations 
happen, items happen out of order by priority, etc... since it just returns 
`undefined` anyway and we are just looking building the error message by then.
   
   As a bit more of an aggressive/refactory PR then, I optimized the piece 
going to run either way ( `responseHeaders` being populated by `Object.assign` 
rather than a faster and more readable `spread` ) ... then go for the gold on 
specificity, since we are still suppressing ( for the programmer ) what is 
going on there and by this point, performance became a lost cause:
   
   ```
       const responseHeaders = {
         uri: scrubURL(req.url),
         statusCode,
         ...(response.headers ?? {})
       };
     
       if (!response.status) {
         log({ err: 'socket', body, headers: responseHeaders })
         if (reject) {
           // since #relax might have sent Error rather than Response:
           const statusText = response.cause?.toString() ?? response.message
           reject(new Error(`error happened in your connection. Reason: 
${statusText}`))
         }
         return
       }
   ```
   
   What do you think? Beyond a happy-medium and get some refactoring started?


-- 
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