thescrublet opened a new issue #252:
URL: https://github.com/apache/couchdb-nano/issues/252


   <!--- Provide a general summary of the issue in the Title above -->
   Consider the following code in relax:
   `
   req.httpAgent = cfg.requestDefaults.agent || defaultHttpAgent
   req.httpsAgent = cfg.requestDefaults.agent || defaultHttpsAgent
   
   // scrub and log
   const scrubbedReq = JSON.parse(JSON.stringify(req))
   `
   
   I'm having issues where the JSON.stringify can fail due to circular 
references in Socket. Traditionally I've avoided logging Socket objects in my 
code because I've run into this problem before.
   
   ## Expected Behavior
   Code functions as designed.
   
   ## Current Behavior
   TypeError: Converting circular structure to JSON
       --> starting at object with constructor 'Socket'
       |     property '_httpMessage' -> object with constructor 'ClientRequest'
       --- property 'socket' closes the circle 
{"timestamp":"2021-01-14T14:13:20.913Z"}
   
   ## Possible Solution
   I believe the scrubLog should happen BEFORE setting the req.httpAgent and 
req.httpsAgent fields. If you need to get that socket information, debug it.
   
   ## Steps to Reproduce (for bugs)
   I'm still trying to figure out why this happens sometimes and not others. 
For example, I was getting the error on changesReader.start at one point, but 
figured out my code was improperly calling the function multiple times. My 
current code seems fine though:
   `
   this.myDb.changesReader.start({ includeDocs: true }).on("batch", (batch) => 
{ ... }.on("error", (error) => { console.error(error) }`
   
   ## Context
   I'm listening for any event in the database.
   
   ## Your Environment
   <!--- Include as many relevant details about the environment you experienced 
the bug in -->
   * Version used: 9.0.2
   * Browser Name and version: NodeJS 14
   * Operating System and version (desktop or mobile): Docker running CentOS 7
   * Link to your project: private internal
   


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

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


Reply via email to