apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
651 stars 165 forks source link

fix: circular ref error when passing agent #270

Closed bodinsamuel closed 3 years ago

bodinsamuel commented 3 years ago

Overview

When passing an agent to nano, the process of scrubbing and logging breaks because of circular refs. Screenshot 2021-07-15 at 12 56 08

I have fixed by removing the pointer ref, but an other solution would be to use a deref like flatted The agent should still in the original object cfg.requestDefaults (for the line 380)

Testing recommendations

import https from 'https';
import nano from 'nano';

const httpsAgent = new https.Agent(options);
const registry = nano({
  url: <YOUR_URL>,
  requestDefaults: {
    agent: httpsAgent,
    timeout: 15000,
    headers: {
      'user-agent': 'fdfd',
      'Accept-Encoding': 'deflate, gzip',
      'content-type': 'application/json',
      accept: 'application/json',
    },
  },
});

Checklist

bodinsamuel commented 3 years ago

There is not much activity on this repo so not sure if someone is handling it. cc @glynnbird ☺️